- Sort Score
- Result 10 results
- Languages All
Results 411 - 420 of 1,379 for def2 (0.02 sec)
-
tests/test_tutorial/test_custom_response/test_tutorial001b.py
from fastapi.testclient import TestClient from docs_src.custom_response.tutorial001b import app client = TestClient(app) def test_get_custom_response(): response = client.get("/items/") assert response.status_code == 200, response.text assert response.json() == [{"item_id": "Foo"}] def test_openapi_schema(): response = client.get("/openapi.json") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 1K bytes - Viewed (0) -
tests/test_tutorial/test_custom_response/test_tutorial005.py
from fastapi.testclient import TestClient from docs_src.custom_response.tutorial005 import app client = TestClient(app) def test_get(): response = client.get("/") assert response.status_code == 200, response.text assert response.text == "Hello World" def test_openapi_schema(): response = client.get("/openapi.json") assert response.status_code == 200, response.text assert response.json() == {
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 980 bytes - Viewed (0) -
tests/test_additional_response_extra.py
app = FastAPI() @sub_router.get("/") def read_item(): return {"id": "foo"} router.include_router(sub_router, prefix="/items") app.include_router(router) client = TestClient(app) def test_path_operation(): response = client.get("/items/") assert response.status_code == 200, response.text assert response.json() == {"id": "foo"} def test_openapi_schema():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 1.2K bytes - Viewed (0) -
tests/test_deprecated_openapi_prefix.py
@app.get("/app") def read_main(request: Request): return {"message": "Hello World", "root_path": request.scope.get("root_path")} client = TestClient(app) def test_main(): response = client.get("/app") assert response.status_code == 200 assert response.json() == {"message": "Hello World", "root_path": "/api/v1"} def test_openapi(): response = client.get("/openapi.json")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 1.2K bytes - Viewed (0) -
docs_src/handling_errors/tutorial006.py
app = FastAPI() @app.exception_handler(StarletteHTTPException) async def custom_http_exception_handler(request, exc): print(f"OMG! An HTTP error!: {repr(exc)}") return await http_exception_handler(request, exc) @app.exception_handler(RequestValidationError) async def validation_exception_handler(request, exc): print(f"OMG! The client sent invalid data!: {exc}")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Aug 09 11:10:33 UTC 2020 - 928 bytes - Viewed (0) -
tests/test_tutorial/test_response_model/test_tutorial004_py310.py
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Aug 04 20:47:07 UTC 2023 - 5.2K bytes - Viewed (0) -
tests/test_sub_callbacks.py
"{$callback_url}/invoices/{$request.body.id}", response_model=InvoiceEventReceived ) def invoice_notification(body: InvoiceEvent): pass # pragma: nocover class Event(BaseModel): name: str total: float events_callback_router = APIRouter() @events_callback_router.get("{$callback_url}/events/{$request.body.title}") def event_callback(event: Event): pass # pragma: nocover
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 13.8K bytes - Viewed (0) -
tests/test_tutorial/test_header_params/test_tutorial002_an_py310.py
200, {"strange_header": None}, ), ], ) def test(path, headers, expected_status, expected_response, client: TestClient): response = client.get(path, headers=headers) assert response.status_code == expected_status assert response.json() == expected_response @needs_py310 def test_openapi_schema(client: TestClient): response = client.get("/openapi.json")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 4.2K bytes - Viewed (0) -
docs/uk/docs/index.md
app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} @app.get("/items/{item_id}") def read_item(item_id: int, q: Union[str, None] = None): return {"item_id": item_id, "q": q} ``` <details markdown="1"> <summary>Або використайте <code>async def</code>...</summary> Якщо ваш код використовує `async` / `await`, скористайтеся `async def`: ```Python hl_lines="9 14"
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 20 19:20:23 UTC 2024 - 24.2K bytes - Viewed (0) -
tests/test_union_inherited_body.py
@app.post("/items/") def save_union_different_body(item: Union[ExtendedItem, Item]): return {"item": item} client = TestClient(app) def test_post_extended_item(): response = client.post("/items/", json={"name": "Foo", "age": 5}) assert response.status_code == 200, response.text assert response.json() == {"item": {"name": "Foo", "age": 5}} def test_post_item():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 5.2K bytes - Viewed (0)