Home / Function/ test_request_with_depends_annotated() — fastapi Function Reference

test_request_with_depends_annotated() — fastapi Function Reference

Architecture documentation for the test_request_with_depends_annotated() function in test_response_dependency.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  7cf4e86c_7288_35f8_5f1e_7b4d31bc04bc["test_request_with_depends_annotated()"]
  b16d0181_b13b_77f6_4428_f731d5a25f66["test_response_dependency.py"]
  7cf4e86c_7288_35f8_5f1e_7b4d31bc04bc -->|defined in| b16d0181_b13b_77f6_4428_f731d5a25f66
  style 7cf4e86c_7288_35f8_5f1e_7b4d31bc04bc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_response_dependency.py lines 125–145

def test_request_with_depends_annotated():
    """Request type hint should work in dependency chain."""
    app = FastAPI()

    def extract_request_info(request: Request) -> dict:
        return {
            "path": request.url.path,
            "user_agent": request.headers.get("user-agent", "unknown"),
        }

    @app.get("/")
    def endpoint(
        info: Annotated[dict, Depends(extract_request_info)],
    ):
        return info

    client = TestClient(app)
    resp = client.get("/", headers={"user-agent": "test-agent"})

    assert resp.status_code == 200
    assert resp.json() == {"path": "/", "user_agent": "test-agent"}

Domain

Subdomains

Frequently Asked Questions

What does test_request_with_depends_annotated() do?
test_request_with_depends_annotated() is a function in the fastapi codebase, defined in tests/test_response_dependency.py.
Where is test_request_with_depends_annotated() defined?
test_request_with_depends_annotated() is defined in tests/test_response_dependency.py at line 125.

Analyze Your Own Codebase

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

Try Supermodel Free