Home / Function/ test_no_annotated_defaults() — fastapi Function Reference

test_no_annotated_defaults() — fastapi Function Reference

Architecture documentation for the test_no_annotated_defaults() function in test_ambiguous_params.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  8f264cc6_9c21_2715_d7f6_3cfe387c114b["test_no_annotated_defaults()"]
  9588c53b_26fc_238d_e474_2a9ae27eef2d["test_ambiguous_params.py"]
  8f264cc6_9c21_2715_d7f6_3cfe387c114b -->|defined in| 9588c53b_26fc_238d_e474_2a9ae27eef2d
  158c8915_611c_64c9_cffc_1d3d9f3987dc["Path()"]
  8f264cc6_9c21_2715_d7f6_3cfe387c114b -->|calls| 158c8915_611c_64c9_cffc_1d3d9f3987dc
  8864e1f8_8173_ce5c_602b_445aa33f20f8["Query()"]
  8f264cc6_9c21_2715_d7f6_3cfe387c114b -->|calls| 8864e1f8_8173_ce5c_602b_445aa33f20f8
  style 8f264cc6_9c21_2715_d7f6_3cfe387c114b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_ambiguous_params.py lines 11–30

def test_no_annotated_defaults():
    with pytest.raises(
        AssertionError, match="Path parameters cannot have a default value"
    ):

        @app.get("/items/{item_id}/")
        async def get_item(item_id: Annotated[int, Path(default=1)]):
            pass  # pragma: nocover

    with pytest.raises(
        AssertionError,
        match=(
            "`Query` default value cannot be set in `Annotated` for 'item_id'. Set the"
            " default value with `=` instead."
        ),
    ):

        @app.get("/")
        async def get(item_id: Annotated[int, Query(default=1)]):
            pass  # pragma: nocover

Domain

Subdomains

Frequently Asked Questions

What does test_no_annotated_defaults() do?
test_no_annotated_defaults() is a function in the fastapi codebase, defined in tests/test_ambiguous_params.py.
Where is test_no_annotated_defaults() defined?
test_no_annotated_defaults() is defined in tests/test_ambiguous_params.py at line 11.
What does test_no_annotated_defaults() call?
test_no_annotated_defaults() calls 2 function(s): Path, Query.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free