Python pytest cov不与tox一起工作

Python pytest cov不与tox一起工作,python,pytest,coverage.py,tox,pytest-cov,Python,Pytest,Coverage.py,Tox,Pytest Cov,这是我的tox.ini配置 [tox] envlist=py36 [测试] commands=pytest-vv--pep8--flakes\ --cov=quest--cov报告\ 缺少术语--配置文件{posargs} deps=-rrequirements.txt 当我运行tox时,我得到了这个错误 $ tox GLOB sdist-make: /Users/hanxue/DrRed/quest-backend/setup.py py36 inst-nodeps: /Users/hanx

这是我的
tox.ini
配置

[tox]
envlist=py36
[测试]
commands=pytest-vv--pep8--flakes\
--cov=quest--cov报告\
缺少术语--配置文件{posargs}
deps=-rrequirements.txt
当我运行
tox
时,我得到了这个错误

$ tox
GLOB sdist-make: /Users/hanxue/DrRed/quest-backend/setup.py
py36 inst-nodeps: /Users/hanxue/DrRed/quest-backend/.tox/dist/quest-3.0.0.zip
py36 installed: aniso8601==1.2.1,apipkg==1.4,argon2-cffi==16.3.0,cffi==1.10.0,click==6.7,configparser2==4.0.0,execnet==1.5.0,Flask==0.12.2,Flask-Cors==3.0.3,Flask-JWT==0.3.2,Flask-JWT-Extended==3.3.1,Flask-Login==0.4.0,Flask-RESTful==0.3.6,Flask-SocketIO==2.9.2,Flask-SQLAlchemy==2.3.2,gevent==1.2.2,gevent-websocket==0.10.1,greenlet==0.4.12,httplib2==0.10.3,itsdangerous==0.24,Jinja2==2.9.6,MarkupSafe==1.0,matrix==2.0.1,passlib==1.7.1,pep8==1.7.0,psycopg2==2.7.3,py==1.4.34,pycparser==2.18,pyflakes==1.6.0,PyJWT==1.4.2,pytest==3.2.3,pytest-cache==1.0,pytest-flakes==2.0.0,pytest-flask==0.10.0,pytest-pep8==1.0.6,python-dateutil==2.6.1,python-engineio==1.7.0,python-socketio==1.8.1,pytz==2017.2,quest==3.0.0,six==1.10.0,SQLAlchemy==1.1.12,Werkzeug==0.12.2
py36 runtests: PYTHONHASHSEED='65686078'
py36 runtests: commands[0] | pytest -vv --pep8 --flakes --cov=quest --cov-report term-missing --profile
usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --cov=quest --cov-report --profile
  inifile: None
  rootdir: /Users/hanxue/DrRed/quest-backend
ERROR: InvocationError: '/Users/hanxue/DrRed/quest-backend/.tox/py36/bin/pytest -vv --pep8 --flakes --cov=quest --cov-report term-missing --profile'
___________________________________ summary ____________________________________
ERROR:   py36: commands failed
请注意,已安装软件包的列表不包括
pytest cov
覆盖范围
,即使这些软件包明确包含在my
requirements.txt
tox.ini
中,也包括该行

deps = -rrequirements.txt
直接运行
pytest
命令可以正常工作

$PYTHONPATH=src/pytest-vv--pep8--flakes--cov=quest--cov报告术语缺失--profile
如何获取tox安装的缺少的
pytest覆盖率

更新1
requirements.txt的内容

aniso8601==1.2.1
argon2-cffi==16.3.0
cffi==1.10.0
click==6.7
colorama==0.3.9
configparser2==4.0.0
Coverage==4.4.1
Flask==0.12.2
Flask-RESTful==0.3.6
Flask-Login==0.4.0
Flask-Cors==3.0.3
Flask-JWT==0.3.2
Flask-JWT-Extended==3.3.1
Flask-SocketIO==2.9.2
Flask-SQLAlchemy==2.3.2
gevent==1.2.2
gevent-websocket==0.10.1
gprof2dot==2017.9.19
greenlet==0.4.12
httplib2==0.10.3
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
matrix==2.0.1
passlib==1.7.1
psycopg2==2.7.3
pycparser==2.18
PyJWT==1.4.2
pytest==3.2.3
pytest-cache==1.0
pytest-colordots==1.1
pytest-cov==2.5.1
pytest-flakes==2.0.0
pytest-flask==0.10.0
pytest-pep8==1.0.6
pytest-profiling==1.2.11
python-dateutil==2.6.1
python-socketio==1.8.1
python-engineio==1.7.0
pytz==2017.2
six==1.10.0
SQLAlchemy==1.1.12
Werkzeug==0.12.2

tox.ini
中使用的
deps=-rrequirements.txt
tox
创建其虚拟环境后被更改时,tox似乎没有安装额外的需求。我现在不知道这是否是
tox
中的bug

要么删除虚拟环境(
rm-rf.tox
),并允许
tox
使用更新的
requirements.txt
重新创建它们,要么自己更新现有虚拟环境:激活,
pip安装
,在
.tox//code>中的所有虚拟环境上循环停用。差不多

source .tox/py27/bin/activate
pip install --upgrade -r requirements.txt
deactivate
Upd。似乎,仍然开放和讨论

除此之外,我还找到了另外两种方法

使用tox-pip扩展 使用并将其添加到
tox.ini

[tox]
tox_pip_extensions_ext_venv_update = true
重新创建虚拟环境 运行
——每次运行tox之前重新创建

$ tox --recreate && tox

我们能完整地看到您的
requirements.txt
tox.ini
吗?这是我的
tox.ini
完整版。添加了
requirements.txt
tox
已经创建虚拟环境之后,您是否更改了
requirements.txt
?当
requirements.txt
被更改时,
tox
似乎没有安装额外的需求。我在一分钟前找到了它,并被迫删除了所有
tox
的虚拟环境,以使其安装我添加的要求。@phd是的,我在tox创建虚拟环境后更新了
requirements.txt
。如何使用
requirements.txt
中的新增内容强制更新tox虚拟环境?
recreate
可在
tox.ini
中使用。但这会减慢所有
tox
调用的速度。