我有一个名为unit_tests
的tox env,用于尝试使用pytest_django
执行测试。当调用命令tox -e unit_tests
时,我得到下面的InvocationError。如果我手动复制并粘贴命令并运行它我没有问题。为什么tox在这里打得不好?
tox 2.7
pytest 3.1.1
pytest-django-3.1.2
pytest-cov-2.5.1
(my_project) My-MacBook-Pro:project me$ tox -e unit_tests
unit_tests installed: amqp==1.4.9,anyjson==0.3.3,argon2-cffi==16.3.0,awesome-slugify==1.6.5,billiard==3.3.0.23,celery==3.1.25,certifi==2017.7.27.1,cffi==1.10.0,chardet==3.0.4,coverage==4.4.1,defusedxml==0.5.0,Django==1.11,django-allauth==0.32.0,django-appconf==1.0.2,django-braces==1.11.0,django-compressor==2.1.1,django-crispy-forms==1.6.1,django-debug-toolbar==1.8,django-environ==0.4.3,django-model-utils==3.0.0,django-redis==4.8.0,django-test-plus==1.0.18,djangorestframework==3.6.3,factory-boy==2.8.1,Faker==0.7.18,flake8==3.4.0,idna==2.5,kombu==3.0.37,mccabe==0.6.1,oauthlib==2.0.2,olefile==0.44,Pillow==4.2.1,pluggy==0.4.0,psycopg2==2.7.3,py==1.4.34,pycodestyle==2.3.1,pycparser==2.18,pyflakes==1.5.0,pytest==3.2.0,pytest-cov==2.5.1,pytest-django==3.1.2,pytest-sugar==0.8.0,python-dateutil==2.6.1,python3-openid==3.1.0,pytz==2017.2,rcssmin==1.0.6,redis==2.10.5,regex==2017.7.28,requests==2.18.3,requests-oauthlib==0.8.0,rjsmin==1.0.12,six==1.10.0,sqlparse==0.2.3,termcolor==1.1.0,tox==2.7.0,Unidecode==0.4.21,urllib3==1.22,virtualenv==15.1.0,whitenoise==3.3.0
unit_tests runtests: PYTHONHASHSEED='1792992873'
unit_tests runtests: commands[0] | python -m pytest -s --cov-config .coveragerc --cov-report term-missing --cov=. --ds=config.settings.test
Test session starts (platform: darwin, Python 3.5.1, pytest 3.2.0, pytest-sugar 0.8.0)
Django settings: config.settings.test (from command line option)
rootdir: /Users/me/Development/my_project, inifile: pytest.ini
plugins: sugar-0.8.0, django-3.1.2, cov-2.5.1
---------- coverage: platform darwin, python 3.5.1-final-0 -----------
Name Stmts Miss Cover Missing
-----------------------------------------------------------------------------------------
users/__init__.py 0 0 100%
users/adapters.py 9 9 0% 1-13
users/admin.py 27 6 78% 23-28
users/apps.py 6 0 100%
users/migrations/0001_initial.py 10 10 0% 3-20
users/migrations/__init__.py 0 0 100%
users/models.py 36 3 92% 17, 20, 61
users/tests/__init__.py 0 0 100%
users/urls.py 3 3 0% 1-5
users/views.py 23 23 0% 1-45
-----------------------------------------------------------------------------------------
TOTAL 316 183 42%
Results (0.13s):
ERROR: InvocationError: '/Users/me/Development/my_project/.tox/unit_tests/bin/python -m pytest -s --cov-config .coveragerc --cov-report term-missing --cov=. --ds=config.settings.test'
___________________________________________________________________________________________ summary ____________________________________________________________________________________________
ERROR: unit_tests: commands failed
[tox]
skipsdist = true
envlist = flake8, unit_tests
[testenv:flake8]
changedir = project
deps = flake8
commands = flake8 . --exclude=migrations
[testenv:unit_tests]
deps = -rrequirements/test.txt
setenv =
DJANGO_SETTINGS_MODULE=config.settings.test
PYTHON_PATH = project/
changedir = project
commands = python -m pytest -s --cov-config .coveragerc --cov-report term-missing --cov=. --ds=config.settings.test