Python testing
This is very sketchy as I figure out some python testing and debug. Mostly notes for myself. In theory, I should be able to test the package by just calling pytest
at a terminal, but it frequently fails. I get an error
ModuleNotFoundError: No module named 'module_trying_to_test'
The project I’m working in already has pytest set up, but when i call pytest test_script.py
, it can’t find the module I’m developing). The solution seems to be to use
python -m pytest tests/test_script.py
From the project root directory.
It also seems to often work to just run
python -m pytest
Note if you have a file with ‘test’ in the name, pytest
will try to run it. So don’t have e.g. figuring_stuff_out_test.py
in there.