Home / Function/ test_response_with_depends_default() — fastapi Function Reference

test_response_with_depends_default() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

tests/test_response_dependency.py lines 34–51

def test_response_with_depends_default():
    """Response type hint should work with Response = Depends(...)."""
    app = FastAPI()

    def modify_response(response: Response) -> Response:
        response.headers["X-Custom"] = "modified"
        return response

    @app.get("/")
    def endpoint(response: Response = Depends(modify_response)):
        return {"status": "ok"}

    client = TestClient(app)
    resp = client.get("/")

    assert resp.status_code == 200
    assert resp.json() == {"status": "ok"}
    assert resp.headers.get("X-Custom") == "modified"

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free