Testing an API with TestClient
FastAPI's TestClient hands a request straight to your app, with no server running and no port, so a pytest test can check the status code, a header and the JSON body that come back, for a GET and for a POST with a body.
Updated

- Category
- FastAPI
- Level
- Journeyman
- Tags
- Content-Type, End-to-End Test, fastapi, rest-api, TestClient, Unit Test (unit-testing)