Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on lemmy.ml
python·Pythonbyvi21

How do you test request validation in FastAPI?

The default approach involves using TestClient. However, I found that mocking the database, background tasks, etc., is overkill. Do you have any suggestions?

View original on lemmy.ml
6

2 replies

lemmy.ca

If you don't want to test the round trip, have your fastapi routes call some other function and test just that function.

1
vi21reply

Do you mean moving Pydantic models as arguments of other function?

1

You reached the end

How do you test request validation in FastAPI? | Spyke