tox is testing the source code instead of the package? #2360
-
Hi
This is the content of the tox.ini:
These are first 4 lines in init.py:
I was wondering whether tox is testing the package which is created and installed in a new virtual environment or the source code in the file system
In the above tox-test.ini, I am just asking tox to skip on creating the package, but only to create a virtualenv with all packages mentioned in deps and run the tests . But, before running tox using the command: tox -c tox-test.ini,` I renamed the sdk inner directory to be sdk-back and I created a new sdk directory with the same init.py file as in sdk-backup but file1.py and file2.py are now empty files. This is how my project look:
Now, when I am running Am I missing something? How can I be sure that only the package which tox creates is tested and the source code is ignored? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @galsasi1989, a couple of notes:
You can avoid this problem by moving your source code into a There are a couple of blog posts out there about this topic: Also, it is important how you run your tests. You run Did this answer your question? Cheers, |
Beta Was this translation helpful? Give feedback.
-
Hi @jugmac00 Yes, Thanks for your detailed answer! |
Beta Was this translation helpful? Give feedback.
Hi @galsasi1989,
a couple of notes:
You can avoid this problem by moving your source code into a
src
directory.There are a couple of blog posts out there about this topic:
https://web.archive.org/web/20170615032800/https://enotuniq.org/
https://hynek.me/articles/testing-packaging/
https://blog.ganssle.io/articles/2019/08/test-as-installed.html
Also, it is important how you run your tests.
You run
python -m pytest
- this adds the current directory to the path, see https://jugmac00.github.io/til/what-is-the-difference-between-invoking-pytest-and-python-m-pytest/Did this answer your question?
C…