FastAPI 0.115 cheatsheet

FastAPI 0.115: Testing

3 common FastAPI 0.115 tasks.

Install the test tools

TestClient needs httpx, and pytest runs the tests.

pip install pytest httpx

Run the tests

Run every test under the current directory.

pytest

Run one test

Run a single test function and show print output.

pytest tests/test_main.py::test_read_main -s

Was this page helpful?