zezollo
zezollo

Reputation: 5027

How to run a tests suite that comes in a sdist?

I would like to be able to run the tests suite when "mypackage" has been installed via pip.

I have created the mypackage-version.tar.gz file myself, using python setup.py sdist. mypackage-version.tar.gz does contain the tests/ directory (moreover, the .egg-info/SOURCES.txt inside it does list all files under tests/ too).

But after I've run pip install mypackage-version.tar.gz inside a dedicated brand new virtual environment, there is no tests/ directory anywhere in the virtual environment:

$ find ./myvenv/ -name "*tests*"
./myvenv/lib/python3.6/site-packages/pip/_vendor/webencodings/__pycache__/tests.cpython-36.pyc
./myvenv/lib/python3.6/site-packages/pip/_vendor/webencodings/tests.py

Reading pip documentation or the output of pip install --help, I just can't figure out if there's any way to ask pip to install the tests correctly along the rest.

I've also tried to unpack the tests/ directory manually (along with pytest.ini), but the tests do not start because pytest complains about not finding mypackage module (ModuleNotFoundError: No module named 'mypackage'), even if both pytest and mypackage show up in pip list... and both are the ones from the virtual environment (as which command tells), as well as pip and python (that can import mypackage).

Yet manually unpacking looks hacky, so before digging further into this, I'd liked to know what is the right way to go: using pip? Manually unpacking? Anything else? Am I missing something obvious?

EDIT: finally, I could run the manually unpacked tests using python -m pytest. But this remains a workaround, and I'd still liked to know whether there's a more proper (and automated) way to install and run the tests suite

Upvotes: 0

Views: 418

Answers (0)

Related Questions