How do you test request validation in FastAPI?

a year ago by vi21 to c/python

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

bradbeattie 1 point a year ago

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

path: 0 20071530, hotness: undefined, score: 1, children: 1
vi21 1 point a year ago

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

path: 0 20071530 20678289, hotness: undefined, score: 1, children: 0
python

@lemmy.ml

login for more options
3655
109
4

News and discussions about the programming language Python


go to feed...