test_multiple_annotations() — fastapi Function Reference
Architecture documentation for the test_multiple_annotations() function in test_ambiguous_params.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 855800fe_8ed6_9992_2502_3aee9f134f35["test_multiple_annotations()"] 9588c53b_26fc_238d_e474_2a9ae27eef2d["test_ambiguous_params.py"] 855800fe_8ed6_9992_2502_3aee9f134f35 -->|defined in| 9588c53b_26fc_238d_e474_2a9ae27eef2d 8864e1f8_8173_ce5c_602b_445aa33f20f8["Query()"] 855800fe_8ed6_9992_2502_3aee9f134f35 -->|calls| 8864e1f8_8173_ce5c_602b_445aa33f20f8 333c1f6d_844c_a4d9_38c6_08988c9eeebf["Depends()"] 855800fe_8ed6_9992_2502_3aee9f134f35 -->|calls| 333c1f6d_844c_a4d9_38c6_08988c9eeebf style 855800fe_8ed6_9992_2502_3aee9f134f35 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_ambiguous_params.py lines 33–74
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(
AssertionError,
match=(
"Cannot specify `Depends` in `Annotated` and default value"
" together for 'foo'"
),
):
@app.get("/")
async def get2(foo: Annotated[int, Depends(dep)] = Depends(dep)):
pass # pragma: nocover
with pytest.raises(
AssertionError,
match=(
"Cannot specify a FastAPI annotation in `Annotated` and `Depends` as a"
" default value together for 'foo'"
),
):
@app.get("/")
async def get3(foo: Annotated[int, Query(min_length=1)] = Depends(dep)):
pass # pragma: nocover
client = TestClient(app)
response = client.get("/multi-query", params={"foo": "5"})
assert response.status_code == 200
assert response.json() == 5
response = client.get("/multi-query", params={"foo": "123"})
assert response.status_code == 422
response = client.get("/multi-query", params={"foo": "1"})
assert response.status_code == 422
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_multiple_annotations() do?
test_multiple_annotations() is a function in the fastapi codebase, defined in tests/test_ambiguous_params.py.
Where is test_multiple_annotations() defined?
test_multiple_annotations() is defined in tests/test_ambiguous_params.py at line 33.
What does test_multiple_annotations() call?
test_multiple_annotations() calls 2 function(s): Depends, Query.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free