TestClient simulates HTTP requests to the FastAPI application without starting a server, which lets you test routes with pytest. You check the status code and the JSON received. dependency_overrides replaces a dependency, such as the database, with a test version.
Example
client = TestClient(app)
r = client.get('/items')
assert r.status_code == 200