test_merged_mixed_state_lifespans() — fastapi Function Reference
Architecture documentation for the test_merged_mixed_state_lifespans() function in test_router_events.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 503ec5a3_af45_dc91_cbf5_cdb4e015c441["test_merged_mixed_state_lifespans()"] 05561238_1d26_3221_b177_440da9d6e710["test_router_events.py"] 503ec5a3_af45_dc91_cbf5_cdb4e015c441 -->|defined in| 05561238_1d26_3221_b177_440da9d6e710 style 503ec5a3_af45_dc91_cbf5_cdb4e015c441 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_router_events.py lines 223–243
def test_merged_mixed_state_lifespans() -> None:
@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
yield
@asynccontextmanager
async def router_lifespan(app: FastAPI) -> AsyncGenerator[dict[str, bool], None]:
yield {"router": True}
@asynccontextmanager
async def sub_router_lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
yield
sub_router = APIRouter(lifespan=sub_router_lifespan)
router = APIRouter(lifespan=router_lifespan)
app = FastAPI(lifespan=lifespan)
router.include_router(sub_router)
app.include_router(router)
with TestClient(app) as client:
assert client.app_state == {"router": True}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_merged_mixed_state_lifespans() do?
test_merged_mixed_state_lifespans() is a function in the fastapi codebase, defined in tests/test_router_events.py.
Where is test_merged_mixed_state_lifespans() defined?
test_merged_mixed_state_lifespans() is defined in tests/test_router_events.py at line 223.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free