Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python tox命令失败,但完整命令手动工作_Python_Pytest_Tox_Pytest Django - Fatal编程技术网

Python tox命令失败,但完整命令手动工作

Python tox命令失败,但完整命令手动工作,python,pytest,tox,pytest-django,Python,Pytest,Tox,Pytest Django,我有一个名为unit\u tests的tox-env,用于尝试使用pytest\u django执行测试。调用命令tox-e unit_tests时,我得到下面的调用错误。如果我手动复制和粘贴命令并运行它,我就没有问题。为什么托克斯在这里打得不好 tox2.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

我有一个名为
unit\u tests
的tox-env,用于尝试使用
pytest\u django
执行测试。调用命令
tox-e unit_tests
时,我得到下面的调用错误。如果我手动复制和粘贴命令并运行它,我就没有问题。为什么托克斯在这里打得不好

tox2.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检查的内容。通常不会显示退出状态。运行
echo$?
命令后是否立即打印0(成功)或其他内容(失败)?打印出5,但没有错误消息由于pytest失败,tox失败。啊,是的,我现在在文档中看到:
退出代码5:未收集测试
。我只是想为pytest启动我的项目。没有意识到如果现在发现测试,它会抛出错误
[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