简体   繁体   English

如何说服 python tox 仅对可用的 python 解释器运行测试?

[英]How to convince python tox to run tests only for the available python interpreters?

I am using python tox to run python unittest for several versions of python, but these python interpreters are not all available on all machines or platforms where I'm running tox.我正在使用 python tox为多个版本的 python 运行 python unittest,但这些 python 解释器并非在我运行 tox 的所有机器或平台上都可用。

How can I configure tox so it will run tests only when python interpretors are available.如何配置 tox 以便它仅在 python 解释器可用时运行测试。

Example of tox.ini : tox.ini示例:

[tox]
envlist=py25,py27

[testenv]
...
[testenv:py25]
...

The big problem is that I do want to have a list of python environments which is auto-detected.最大的问题是我确实想要一个自动检测到的 python 环境列表。

As of Tox version 1.7.2, you can pass the --skip-missing-interpreters flag to achieve this behavior. 从Tox版本1.7.2开始,您可以传递--skip-missing-interpreters标志来实现此行为。 You can also set skip_missing_interpreters=true in your tox.ini file. 您还可以在tox.ini文件中设置skip_missing_interpreters=true More info here . 更多信息在这里

[tox]
envlist =
    py24, py25, py26, py27, py30, py31, py32, py33, py34, jython, pypy, pypy3
skip_missing_interpreters =
    true

First if you don't have tox : pip install tox .首先,如果您没有 tox : pip install tox

Use this command : tox --skip-missing-interpreters , it skips for the compilers which are not available locally and just runs for the available versions of python使用这个命令: tox --skip-missing-interpreters ,它跳过本地不可用的编译器,只为可用版本的python运行

tox will display an Error if an interpreter cannot be found. 如果找不到解释器,tox将显示错误。 Question is up if there should be a "SKIPPED" state and making tox return a "0" success result. 如果应该有“SKIPPED”状态并使tox返回“0”成功结果,则问题就出现了。 This should probably be explicitely enabled via a command line option. 这可能应该通过命令行选项明确启用。 If you agree, file an issue at http://bitbucket.org/hpk42/tox . 如果您同意,请在http://bitbucket.org/hpk42/tox上提交问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM