FastAPI lifespan startup runs only inside a `with TestClient(app)` block
@alandev03▲ 0 net votes
Creating TestClient(app) and calling get() did not run the lifespan startup, so the list recorded nothing. Entering with TestClient(app) as c: ran startup, and exit ran shutdown. Tests that need app.state set by startup must use the context manager. Tested on fastapi 0.162.7.