Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.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警告:在testenv中找到但未安装测试命令_Python_Unit Testing_Pylint_Tox - Fatal编程技术网

Python Tox警告:在testenv中找到但未安装测试命令

Python Tox警告:在testenv中找到但未安装测试命令,python,unit-testing,pylint,tox,Python,Unit Testing,Pylint,Tox,我正在为我的项目使用tox 这是我的tox.ini文件: [tox] envlist = py27, lint, coverage skipsdist = True [testenv:py27] deps = -rrequirements.txt commands = python -m unittest discover -s ./tests [testenv:coverage] commands = coverage run --source=tests

我正在为我的项目使用tox

这是我的
tox.ini
文件:

[tox]
envlist =
    py27,
    lint,
    coverage

skipsdist = True

[testenv:py27]
deps = -rrequirements.txt
commands = python -m unittest discover -s ./tests

[testenv:coverage]
commands =
    coverage run --source=tests -m unittest discover -s tests/
    coverage html
    coverage report


[testenv:lint]
commands = pylint ./foo
每当我运行tox时,所有的东西都会被执行,基本上就是linting,coverage

但是毒物检测显示了对一切的警告

WARNING:test command found but not installed in testenv
Maybe you forgot to specify a dependency? See also the whitelist_externals envconfig setting.
一切都成功了,但它仍然显示警告和错误。谁能告诉我我做错了什么

我的
requirements.txt
文件如下:

requests==2.18.4
JsonForm==0.0.2
jsonify==0.5
jsonschema==2.6.0
JsonSir==0.0.2
python-dateutil==1.5
DateTime==4.2
urllib3==1.22
contextlib2==0.5.5
mock==2.0.0
patch==1.16

您在
命令中使用的程序必须安装在tox的虚拟环境中或列入白名单:

[tox]
envlist =
    py27,
    lint,
    coverage

skipsdist = True

[testenv:py27]
deps = -rrequirements.txt
whitelist_externals = python
commands = python -m unittest discover -s ./tests

[testenv:coverage]
whitelist_externals = coverage
commands =
    coverage run --source=tests -m unittest discover -s tests/
    coverage html
    coverage report


[testenv:lint]
whitelist_externals = pylint
commands = pylint ./foo

在这里,设置这个选项,也许,你通过了

sitepackages=false(true | false) 如果要创建也可以访问全局安装的软件包的虚拟环境,请设置为true

警告 在全局安装命令行工具的情况下,必须确保使用python-m(如果该工具支持)或{envbindir}/来使用安装在virtualenv中的工具

如果您忘记这样做,您将收到如下警告:

WARNING: test command found but not installed in testenv
    cmd: /path/to/parent/interpreter/bin/<some command>
    env: /foo/bar/.tox/python
Maybe you forgot to specify a dependency? See also the whitelist_externals envconfig setting.
警告:在testenv中找到但未安装测试命令
cmd:/path/to/parent/explorer/bin/
env:/foo/bar/.tox/python
也许您忘记指定依赖项了?另请参见白名单\u外部环境配置设置。

这个问题很老,但答案不适用于我的情况。在我的例子中,一旦我将
[testenv]
更改为
[env]
,它就可以工作了。这是因为我的Python虚拟环境名为“env”。

我不知道为什么,但为了解决这个问题,我不得不再次克隆我的repo。回购重置不仅解决完整克隆问题


签出查看更多详细信息。

如果在需求中配置pylint和coverage,是否会出现相同的错误?刚刚选中,是的,它显示了相同的错误,但我得到了所需的输出,但我无法理解为什么会出现警告:错误消失了,但这是因为它不再找到定义
testenv
。将
testenv
重命名为
env
不是一个好办法!从那时起,您的测试就不会被执行。不确定为什么
python
需要被列入白名单-它应该在virtualenv中!但我认为这是最好的答案,应该接受-@primer?