- Sort Score
- Result 10 results
- Languages All
Results 191 - 200 of 1,379 for def2 (0.02 sec)
-
tests/test_ambiguous_params.py
" default value with `=` instead." ), ): @app.get("/") async def get(item_id: Annotated[int, Query(default=1)]): pass # pragma: nocover def test_multiple_annotations(): async def dep(): pass # pragma: nocover @app.get("/multi-query") async def get(foo: Annotated[int, Query(gt=2), Query(lt=10)]): return foo with pytest.raises(
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Dec 12 00:22:47 UTC 2023 - 2.1K bytes - Viewed (0) -
tests/test_route_scope.py
client = TestClient(app) def test_get(): response = client.get("/users/rick") assert response.status_code == 200, response.text assert response.json() == {"user_id": "rick", "path": "/users/{user_id}"} def test_invalid_method_doesnt_match(): response = client.post("/users/rick") assert response.status_code == 405, response.text def test_invalid_path_doesnt_match():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Wed Feb 08 10:23:07 UTC 2023 - 1.5K bytes - Viewed (0) -
docs_src/dependency_testing/tutorial001_py310.py
from fastapi.testclient import TestClient app = FastAPI() async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100): return {"q": q, "skip": skip, "limit": limit} @app.get("/items/") async def read_items(commons: dict = Depends(common_parameters)): return {"message": "Hello Items!", "params": commons} @app.get("/users/") async def read_users(commons: dict = Depends(common_parameters)):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 1.4K bytes - Viewed (0) -
docs_src/dependencies/tutorial008_an_py39.py
from fastapi import Depends async def dependency_a(): dep_a = generate_dep_a() try: yield dep_a finally: dep_a.close() async def dependency_b(dep_a: Annotated[DepA, Depends(dependency_a)]): dep_b = generate_dep_b() try: yield dep_b finally: dep_b.close(dep_a) async def dependency_c(dep_b: Annotated[DepB, Depends(dependency_b)]):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 521 bytes - Viewed (0) -
tests/test_openapi_separate_input_output_schemas.py
def get_app_client(separate_input_output_schemas: bool = True) -> TestClient: app = FastAPI(separate_input_output_schemas=separate_input_output_schemas) @app.post("/items/", responses={402: {"model": Item}}) def create_item(item: Item) -> Item: return item @app.post("/items-list/") def create_item_list(item: List[Item]): return item
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Oct 12 09:44:57 UTC 2024 - 19.7K bytes - Viewed (0) -
docs_src/app_testing/tutorial003.py
from fastapi.testclient import TestClient app = FastAPI() items = {} @app.on_event("startup") async def startup_event(): items["foo"] = {"name": "Fighters"} items["bar"] = {"name": "Tenders"} @app.get("/items/{item_id}") async def read_items(item_id: str): return items[item_id] def test_read_items(): with TestClient(app) as client: response = client.get("/items/foo")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Mar 26 19:09:53 UTC 2020 - 528 bytes - Viewed (0) -
docs_src/dependencies/tutorial001_02_an_py39.py
app = FastAPI() async def common_parameters( q: Union[str, None] = None, skip: int = 0, limit: int = 100 ): return {"q": q, "skip": skip, "limit": limit} CommonsDep = Annotated[dict, Depends(common_parameters)] @app.get("/items/") async def read_items(commons: CommonsDep): return commons @app.get("/users/") async def read_users(commons: CommonsDep):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 466 bytes - Viewed (0) -
docs_src/dependencies/tutorial005_an_py39.py
from fastapi import Cookie, Depends, FastAPI app = FastAPI() def query_extractor(q: Union[str, None] = None): return q def query_or_cookie_extractor( q: Annotated[str, Depends(query_extractor)], last_query: Annotated[Union[str, None], Cookie()] = None, ): if not q: return last_query return q @app.get("/items/") async def read_query(
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 529 bytes - Viewed (0) -
tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py
import pytest from fastapi.testclient import TestClient from ...utils import needs_py39 @pytest.fixture(name="client") def get_client(): from docs_src.dependencies.tutorial008b_an_py39 import app client = TestClient(app) return client @needs_py39 def test_get_no_item(client: TestClient): response = client.get("/items/foo") assert response.status_code == 404, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Feb 24 23:06:37 UTC 2024 - 918 bytes - Viewed (0) -
docs_src/dependency_testing/tutorial001_an.py
app = FastAPI() async def common_parameters( q: Union[str, None] = None, skip: int = 0, limit: int = 100 ): return {"q": q, "skip": skip, "limit": limit} @app.get("/items/") async def read_items(commons: Annotated[dict, Depends(common_parameters)]): return {"message": "Hello Items!", "params": commons} @app.get("/users/")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 1.5K bytes - Viewed (0)