sampleproject icon indicating copy to clipboard operation
sampleproject copied to clipboard

How do you test this?

Open myarcana opened this issue 3 years ago • 2 comments

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?

myarcana avatar Nov 20 '22 14:11 myarcana

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

dmtucker avatar Nov 20 '22 17:11 dmtucker

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)

pwihmag avatar Jan 31 '24 07:01 pwihmag