Reputation: 12065
I'm running a super simple tox.ini
file based on the Tox basic example and a walkthrough video entitled Automating Build, Test and Release Workflows with tox. The problem is everytime I run the tox
command, I get a bunch of invocation errors and "ERROR: file not found:
tox.ini
:# tox (https://tox.readthedocs.io/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
skipsdist = true
envlist = py36, py37, build
skip_missing_interpreters = true
[testenv]
whitelist_externals = *
passenv = *
deps = -rrequirements-test.txt
commands = {[testenv:unit]commands}
[travis]
python =
3.6: py36
3.7: py37, build
[testenv:unit]
deps = {[testenv]deps}
commands = pytest {posargs:--cov={envsitepackagesdir}/project_name {envsitepackagesdir}/project_name src/tests}
[testenv:test]
deps =
{[testenv]deps}
{[testenv:build]deps}
commands =
{[testenv:unit]commands}
{[testenv:build]commands}
[testenv:build]
skip_install = true
deps =
wheel
commands =
rm -rf dist build
python -W ignore setup.py -q sdist bdist_wheel
;[testenv:release]
;deps =
; {[testenv:build]deps}
; twine
;commands =
; {[testenv:build]commands}
; twine upload dist/*
;
# From https://pytest-cov.readthedocs.io/en/latest/tox.html
[testenv:clean]
deps = coverage
skip_install = true
commands = coverage erase
[pytest]
addopts =
-v -s
--color=yes
--cov
--cov-append
--cov-report=term-missing
--cov-config=setup.cfg
[coverage:run]
omit =
*/tests/*
*/test_*
*/distutils/*
*/site-packages/*
[coverage:report]
show_missing = True
[flake8]
exclude = .tox
[report]
omit = */usr/*
$ tox
py36 create: /path/to/my/project/python/project_namepy/.tox/py36
py36 installdeps: -rrequirements-test.txt
py36 installed: atomicwrites==1.3.0,attrs==19.1.0,bleach==3.1.0,certifi==2019.6.16,chardet==3.0.4,colorama==0.4.1,coverage==4.5.4,docutils==0.15.2,Faker==2.0.0,filelock==3.0.12,idna==2.8,importlib-metadata==0.19,more-itertools==7.2.0,packaging==19.1,pkginfo==1.5.0.1,pluggy==0.12.0,py==1.8.0,Pygments==2.4.2,pyparsing==2.4.2,pytest==5.0.1,pytest-cov==2.7.1,python-dateutil==2.8.0,readme-renderer==24.0,requests==2.22.0,requests-toolbelt==0.9.1,six==1.12.0,text-unidecode==1.2,toml==0.10.0,tox==3.13.2,tqdm==4.33.0,twine==1.13.0,urllib3==1.25.3,virtualenv==16.7.2,wcwidth==0.1.7,webencodings==0.5.1,zipp==0.5.2
py36 run-test-pre: PYTHONHASHSEED='2972258678'
py36 run-test: commands[0] | pytest --cov=/path/to/my/project/python/project_namepy/.tox/py36/lib/python3.6/site-packages/project_name /path/to/my/project/python/project_namepy/.tox/py36/lib/python3.6/site-packages/project_name src/tests
==================================================================================== test session starts ====================================================================================
platform darwin -- Python 3.6.5, pytest-5.0.1, py-1.8.0, pluggy-0.12.0 -- /usr/local/Cellar/python/3.6.5/bin/python3.6
cachedir: .tox/py36/.pytest_cache
rootdir: /path/to/my/project/python/project_namepy, inifile: tox.ini
plugins: cov-2.7.1
collected 0 items
=============================================================================== no tests ran in 0.02 seconds ================================================================================
ERROR: file not found: /path/to/my/project/python/project_namepy/.tox/py36/lib/python3.6/site-packages/project_name
ERROR: InvocationError for command /path/to/my/project/python/project_namepy/.tox/py36/bin/pytest --cov=/path/to/my/project/python/project_namepy/.tox/py36/lib/python3.6/site-packages/project_name /path/to/my/project/python/project_namepy/.tox/py36/lib/python3.6/site-packages/project_name src/tests (exited with code 4)
py37 create: /path/to/my/project/python/project_namepy/.tox/py37
py37 installdeps: -rrequirements-test.txt
py37 installed: atomicwrites==1.3.0,attrs==19.1.0,bleach==3.1.0,certifi==2019.6.16,chardet==3.0.4,colorama==0.4.1,coverage==4.5.4,docutils==0.15.2,Faker==2.0.0,filelock==3.0.12,idna==2.8,importlib-metadata==0.19,more-itertools==7.2.0,packaging==19.1,pkginfo==1.5.0.1,pluggy==0.12.0,py==1.8.0,Pygments==2.4.2,pyparsing==2.4.2,pytest==5.0.1,pytest-cov==2.7.1,python-dateutil==2.8.0,readme-renderer==24.0,requests==2.22.0,requests-toolbelt==0.9.1,six==1.12.0,text-unidecode==1.2,toml==0.10.0,tox==3.13.2,tqdm==4.33.0,twine==1.13.0,urllib3==1.25.3,virtualenv==16.7.2,wcwidth==0.1.7,webencodings==0.5.1,zipp==0.5.2
py37 run-test-pre: PYTHONHASHSEED='2972258678'
py37 run-test: commands[0] | pytest --cov=/path/to/my/project/python/project_namepy/.tox/py37/lib/python3.7/site-packages/project_name /path/to/my/project/python/project_namepy/.tox/py37/lib/python3.7/site-packages/project_name src/tests
==================================================================================== test session starts ====================================================================================
platform darwin -- Python 3.7.4, pytest-5.0.1, py-1.8.0, pluggy-0.12.0 -- /usr/local/Cellar/python/3.6.5/bin/python3.6
cachedir: .tox/py37/.pytest_cache
rootdir: /path/to/my/project/python/project_namepy, inifile: tox.ini
plugins: cov-2.7.1
collected 0 items
=============================================================================== no tests ran in 0.01 seconds ================================================================================
ERROR: file not found: /path/to/my/project/python/project_namepy/.tox/py37/lib/python3.7/site-packages/project_name
ERROR: InvocationError for command /path/to/my/project/python/project_namepy/.tox/py37/bin/pytest --cov=/path/to/my/project/python/project_namepy/.tox/py37/lib/python3.7/site-packages/project_name /path/to/my/project/python/project_namepy/.tox/py37/lib/python3.7/site-packages/project_name src/tests (exited with code 4)
build create: /path/to/my/project/python/project_namepy/.tox/build
build installdeps: wheel
build run-test-pre: PYTHONHASHSEED='2972258678'
build run-test: commands[0] | rm -rf dist build
build run-test: commands[1] | python -W ignore setup.py -q sdist bdist_wheel
__________________________________________________________________________________________ summary __________________________________________________________________________________________
ERROR: py36: commands failed
ERROR: py37: commands failed
build: commands succeeded
Upvotes: 1
Views: 3450
Reputation: 12065
During the aforementioned video, one of the first line items in the tox.ini
setup is writing the line having to do with skipping the creation of the sdist
, which is considered "expensive":
[tox]
skipsdist = true
It turns out this is a very important step if your tests rely on importing your package (hint: they pretty much have to. Otherwise, what are they testing?). The narrator of the video (and also a key contributor to the project) does mention installing the package in "development" mode (pip install -e .
), but neglects to mention (or perhaps I misheard) that the package does actually need to be installed at some point.
Changing this value to skipsdist = false
or simply removing the line completely fixes the issue.
Upvotes: 2