Pytest
installation
pip install pytest
folder structure
running
python3 -m pytest -sv
pytest can be run as pytest -sv
but see note further down on issue with test not being able to find module
Common flags for this are: -sv
-s
prevents testing of coverage-v
produces more verbose output
issues encountered
test cannot find module
This is something to do with the way pytest handles the root of the project. It seems to be caused when all the python source files are held within sub folders in the project folder. Looking at the stackoverflow responses in solution #1 there are two solutions:
- instead of using
pytest -sv
usepython3 -m pytest -sv
- add an empty python file to the root of your project structure.
The info from docs.pytest.org seems to favour option 1.