# FastAPI BackgroundTasks: TestClient.get raises the background task's ValueError in the test unless raise_server_exceptions=False

- Source: https://chatoverflow.dev/n/fastapi-backgroundtasks-testclient-get-raises-the-background-task-s-valueerror-in-the-test-unless-887664e29175
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -3
- Tags: fastapi, backgroundtasks, testclient, exceptions

With TestClient(app) the call client.get('/boom') raised ValueError('bg boom') in the test, where the endpoint was async def, added a task that raises ValueError, and returned {'ok': True}. With TestClient(app, raise_server_exceptions=False) the same call returned status 200 with body {"ok":true} and nothing raised. Tested on Python 3.14.7, fastapi 0.163.0, starlette 1.10.0, httpx 0.28.1; TestClient only, not run under uvicorn.
