首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pytest-cov不适用于毒理

pytest-cov不适用于毒理
EN

Stack Overflow用户
提问于 2017-10-25 09:54:15
回答 2查看 2.6K关注 0票数 5

这是我的tox.ini配置

代码语言:javascript
复制
[tox]
envlist = py36

[testenv]
commands = pytest -vv --pep8 --flakes \
            --cov=quest --cov-report \
            term-missing --profile {posargs}
deps = -rrequirements.txt

当我运行tox时,我会得到这个错误

代码语言:javascript
复制
$ 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-covcoverage,尽管这些包显式地包含在coveragerequirements.txt中,tox.ini包含行

代码语言:javascript
复制
deps = -rrequirements.txt

直接运行pytest命令很好

代码语言:javascript
复制
$ PYTHONPATH=src/ pytest -vv --pep8 --flakes --cov=quest --cov-report term-missing --profile

如何通过毒物检验来安装缺少的pytest-coverage库?

更新1

requirements.txt含量

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-10-26 21:00:00

requirements.txt创建虚拟环境之后,在tox.inideps = -rrequirements.txt中使用的deps = -rrequirements.txt被更改时,tox似乎不会安装额外的要求。如果这是tox中的bug,我现在就不知道了。

要么删除虚拟环境(rm -rf .tox)并允许tox用更新的requirements.txt重新创建它们,要么自己更新现有的虚拟环境: activate,pip install,在.tox/中所有虚拟环境的循环中禁用。有点像

代码语言:javascript
复制
source .tox/py27/bin/activate
pip install --upgrade -r requirements.txt
deactivate

Upd。似乎是一个已知的老问题,仍然开放和讨论。

在requirements.txt或setup.py更改时用tox重新安装virtualenv

票数 2
EN

Stack Overflow用户

发布于 2017-10-27 05:47:52

除了@博士生答案之外,我还找到了另外两种方法。

使用毒物止痛剂

使用[医]毒瘾扩大器并将其添加到tox.ini

代码语言:javascript
复制
[tox]
tox_pip_extensions_ext_venv_update = true

重新创建虚拟环境

每次运行毒理前运行--recreate

代码语言:javascript
复制
$ tox --recreate && tox
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46929315

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档