Closed parisni closed 1 year ago
This is intentional - you are prevented to run the code without installing it. I wrote about this here https://blog.ionelmc.ro/2014/05/25/python-packaging/
If you'd like to work virtualenv-style on your project then perhaps run something alone these lines?
source .tox/py38/bin/activate
pytest ...
then what trick in the tox.ini makes pytest working then ? I cannot figure out. For example, PYTHONPATH=tests shouldn't help
It installs your code in the virtualenv (eg .tox/py38). This a bit more complicated but it could be summed up as python setup.py sdist && .tox/py38/bin/pip install .tox/dists/project-0.1.tar.gz
or something like that.
Where are you going with this? What's the actual problem you're having?
well, i am trying to reproduce your config on one on my existing project (moving the project_name into src/project_name) and so far my pytests are not running as smoth as before. Anyway thanks for your efforts/time ! This is a hot topic.
Well you need to install the code into the virtualenv you're gonna tests with. At the very least a venv/bin/python setup.py install
. Or just use tox?
hi,
I installed a python-nameless project with pytest support.
tox
works out of the box for testing.However, running
pytest
does not (see below). The only way to make it work is by runningPYTHONPATH=src pytest
or by adding an emptyconftest.py
into src. BTW, I cannot figure out why tox is running pytest without trouble.Thanks for the explanations