python - 毒性警告 :test command found but not installed in testenv

标签 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 -m unittest discover -s tests/
    coverage html
    coverage report


[testenv:lint]
commands = pylint ./foo

每当我运行 tox 时,一切都会被执行,这基本上是 linting、覆盖率。

但 Tox 对所有内容都显示警告。

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

最佳答案

您在 commands 中使用的程序必须安装在 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

关于python - 毒性警告 :test command found but not installed in testenv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47642747/

相关文章:

python - 如何使用 Pandas、Numpy 加速 Python 中的嵌套 for 循环逻辑?

unit-testing - 作为科学程序员/学生/研究人员,我如何将 TDD 纳入我的工作流程?

python-3.x - Visual Studio Code,pylint 提示 "Unable to import XXX"

python - 如何将 Pylint 与 Geany 集成,以便我可以将 Geany 用作 python IDE?

javascript - 如何使用 Karma、Jasmine 和 Istanbul 指定测试应涵盖哪些功能/方法

python - pylint 报告通过 simplejson 加载的数据可能没有成员错误

Python:将变量的值转换为函数的名称?

python - 这是否为我的分类分类提供了良好的基线?

python - 在 Python 中单击按钮时隐藏标签

ios - 单元测试中的属性为零