Home / Function/ test_router_nested_lifespan_state_overriding_by_parent() — fastapi Function Reference

test_router_nested_lifespan_state_overriding_by_parent() — fastapi Function Reference

Architecture documentation for the test_router_nested_lifespan_state_overriding_by_parent() function in test_router_events.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  bdc7b6f8_1006_c437_8b74_f4ef940bd830["test_router_nested_lifespan_state_overriding_by_parent()"]
  05561238_1d26_3221_b177_440da9d6e710["test_router_events.py"]
  bdc7b6f8_1006_c437_8b74_f4ef940bd830 -->|defined in| 05561238_1d26_3221_b177_440da9d6e710
  style bdc7b6f8_1006_c437_8b74_f4ef940bd830 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_router_events.py lines 175–203

def test_router_nested_lifespan_state_overriding_by_parent() -> None:
    @asynccontextmanager
    async def lifespan(
        app: FastAPI,
    ) -> AsyncGenerator[dict[str, Union[str, bool]], None]:
        yield {
            "app_specific": True,
            "overridden": "app",
        }

    @asynccontextmanager
    async def router_lifespan(
        app: FastAPI,
    ) -> AsyncGenerator[dict[str, Union[str, bool]], None]:
        yield {
            "router_specific": True,
            "overridden": "router",  # should override parent
        }

    router = APIRouter(lifespan=router_lifespan)
    app = FastAPI(lifespan=lifespan)
    app.include_router(router)

    with TestClient(app) as client:
        assert client.app_state == {
            "app_specific": True,
            "router_specific": True,
            "overridden": "app",
        }

Domain

Subdomains

Frequently Asked Questions

What does test_router_nested_lifespan_state_overriding_by_parent() do?
test_router_nested_lifespan_state_overriding_by_parent() is a function in the fastapi codebase, defined in tests/test_router_events.py.
Where is test_router_nested_lifespan_state_overriding_by_parent() defined?
test_router_nested_lifespan_state_overriding_by_parent() is defined in tests/test_router_events.py at line 175.

Analyze Your Own Codebase

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

Try Supermodel Free