Home / File/ test_annotated.py — fastapi Source File

test_annotated.py — fastapi Source File

Architecture documentation for test_annotated.py, a python file in the fastapi codebase. 5 imports, 0 dependents.

File python FastAPI Routing 5 imports 8 functions

Entity Profile

Dependency Diagram

graph LR
  ebdf85eb_0692_0882_dd01_47bca11b24da["test_annotated.py"]
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  ebdf85eb_0692_0882_dd01_47bca11b24da --> 0dda2280_3359_8460_301c_e98c77e78185
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  ebdf85eb_0692_0882_dd01_47bca11b24da --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  ebdf85eb_0692_0882_dd01_47bca11b24da --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  ebdf85eb_0692_0882_dd01_47bca11b24da --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  ebdf85eb_0692_0882_dd01_47bca11b24da --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  style ebdf85eb_0692_0882_dd01_47bca11b24da fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Annotated

import pytest
from fastapi import APIRouter, FastAPI, Query
from fastapi.testclient import TestClient
from inline_snapshot import snapshot

app = FastAPI()


@app.get("/default")
async def default(foo: Annotated[str, Query()] = "foo"):
    return {"foo": foo}


@app.get("/required")
async def required(foo: Annotated[str, Query(min_length=1)]):
    return {"foo": foo}


@app.get("/multiple")
async def multiple(foo: Annotated[str, object(), Query(min_length=1)]):
    return {"foo": foo}


@app.get("/unrelated")
async def unrelated(foo: Annotated[str, object()]):
    return {"foo": foo}


client = TestClient(app)

foo_is_missing = {
    "detail": [
        {
            "loc": ["query", "foo"],
            "msg": "Field required",
            "type": "missing",
            "input": None,
        }
    ]
}
foo_is_short = {
    "detail": [
        {
            "ctx": {"min_length": 1},
            "loc": ["query", "foo"],
            "msg": "String should have at least 1 character",
            "type": "string_too_short",
            "input": "",
        }
    ]
}


@pytest.mark.parametrize(
    "path,expected_status,expected_response",
    [
        ("/default", 200, {"foo": "foo"}),
        ("/default?foo=bar", 200, {"foo": "bar"}),
// ... (239 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_annotated.py do?
test_annotated.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Routing subdomain.
What functions are defined in test_annotated.py?
test_annotated.py defines 8 function(s): default, multiple, required, test_get, test_multiple_path, test_nested_router, test_openapi_schema, unrelated.
What does test_annotated.py depend on?
test_annotated.py imports 5 module(s): __init__.py, inline_snapshot, pytest, testclient.py, typing.
Where is test_annotated.py in the architecture?
test_annotated.py is located at tests/test_annotated.py (domain: FastAPI, subdomain: Routing, directory: tests).

Analyze Your Own Codebase

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

Try Supermodel Free