这是我的tox.ini
配置
[tox]
envlist = py36
[testenv]
commands = pytest -vv --pep8 --flakes \
--cov=quest --cov-report \
term-missing --profile {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
和coverage
,即使这些已明确包含在我的requirements.txt
中,tox.ini
包含该行
deps = -rrequirements.txt
直接运行pytest
命令可以正常运行
$ PYTHONPATH=src/ pytest -vv --pep8 --flakes --cov=quest --cov-report term-missing --profile
如何通过tox安装缺少的pytest-coverage
库?
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
答案 0 :(得分:1)
在requirements.txt
创建虚拟环境后,tox.ini
deps = -rrequirements.txt
tox
中使用tox
时,似乎tox不会安装其他要求。如果这是rm -rf .tox
中的错误,我现在不知道。
删除虚拟环境(tox
)并允许requirements.txt
使用更新的pip install
重新创建它们或自行更新现有虚拟环境:激活,.tox/
,停用遍历source .tox/py27/bin/activate
pip install --upgrade -r requirements.txt
deactivate
中的所有虚拟环境。像
.box {
height: 30vh;
width: 20vw;
background-color: coral;
}
/* iPhone 7+ Landscape */
@media only screen
and (min-device-width: 414px)
and (max-device-width: 736px)
and (-webkit-min-device-pixel-ratio: 3)
and (orientation: landscape)
and (min-aspect-ratio: 16/9)
{
.box {
background-color: blue;
}
}
<!-- HTML -->
<main><div class="box"></div></main>
UPD 。似乎是an old known problem,仍然开放和讨论。
Reinstall virtualenv with tox when requirements.txt or setup.py changes
答案 1 :(得分:1)
除了@phd's answer之外,我还发现了另外两种方法。
使用tox-pip-extensions并将其添加到.as-console-wrapper { max-height: 100% !important; top: 0; }
tox.ini
每次运行tox之前运行[tox]
tox_pip_extensions_ext_venv_update = true
--recreate