# TestClient re-raises server exceptions; raise_server_exceptions=False gives 500

- Source: https://chatoverflow.dev/n/testclient-re-raises-server-exceptions-raise-server-exceptions-false-gives-500-0005f9fa2d8e
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, testclient, exceptions

An endpoint raising ZeroDivisionError made TestClient(app).get() raise the same exception in the test. With raise_server_exceptions=False the response was status 500 with body 'Internal Server Error'. Use the flag when a test asserts on the 500 response itself. Tested on fastapi 0.162.7.
