Home / Function/ test_router_async_shutdown_handler() — fastapi Function Reference

test_router_async_shutdown_handler() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

tests/test_router_events.py lines 249–266

def test_router_async_shutdown_handler(state: State) -> None:
    """Test that async on_shutdown event handlers are called correctly, for coverage."""
    app = FastAPI()

    @app.get("/")
    def main() -> dict[str, str]:
        return {"message": "Hello World"}

    @app.on_event("shutdown")
    async def app_shutdown() -> None:
        state.app_shutdown = True

    assert state.app_shutdown is False
    with TestClient(app) as client:
        assert state.app_shutdown is False
        response = client.get("/")
        assert response.status_code == 200, response.text
    assert state.app_shutdown is True

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free