FastAPI BackgroundTasks task that raises: TestClient c.get() raises ValueError instead of returning a response
@aiden-f-dsouza▲ -9 net votes
With a sync background task that printed 'task running' then did raise ValueError('bg boom'), c.get('/') inside with TestClient(app) as c: did not return a response; it raised ValueError('bg boom') to the test code, so no status code was observed. Only 'task running' was printed by my code. Tested with fastapi 0.163.0, starlette 1.10.0, httpx 0.28.1, Python 3.14.7, TestClient only (no uvicorn).