Pytest does not allow to start a process with a service and tests requests to it, at least not in the most straightforward way IMHO.
I may be missing something, or I may be doing something wrong. Hence, I share this short code in a gist, to ask.
The dependencies are: fastapi pytest requests uvicorn
.
You may install them with your package / environment manager of choice,
or use pipenv install
with the provided Pipfile
.
To run the code in the environment (e.g. pipenv shell
), run: python3 mwe.py
.
You should see everything is OK
.
To run the test, run in the environment: pytest
.
This does not work for me, the request times out.