sampleproject
sampleproject copied to clipboard
How do you test this?
Both python tests/test_simple.py and python -m unittest discover throw errors because of the import
File "sampleproject/tests/test_simple.py", line 7, in <module>
from sample.simple import add_one
ModuleNotFoundError: No module named 'sample'
So what's the correct way to test this package and other packages while in development?
This project has a tox.ini file to automate running the tests: https://tox.wiki/en/latest/index.html
tox
To run manually, you must install the project before it can be tested:
python3 -m venv myvenv
myvenv/bin/python -m pip install .
myvenv/bin/python -m unittest discover
I have installed tox, but that gave a lot of errors: ./.venv/lib/python3.10/site-packages/virtualenv/seed/wheels/util.py:68:52: E203 whitespace before ':' ./.venv/lib/python3.10/site-packages/virtualenv/seed/wheels/util.py:69:80: E501 line too long (100 > 79 characters) ./.venv/lib/python3.10/site-packages/virtualenv/seed/wheels/util.py:88:13: W503 line break before binary operator ./.venv/lib/python3.10/site-packages/virtualenv/seed/wheels/util.py:89:13: W503 line break before binary operator ./.venv/lib/python3.10/site-packages/virtualenv/seed/wheels/util.py:90:13: W503 line break before binary operator ./.venv/lib/python3.10/site-packages/virtualenv/seed/wheels/util.py:93:80: E501 line too long (88 > 79 characters)