简体   繁体   English

tox 命令运行所有条件

[英]tox command to run all conditionals

Given this simplified tox file below, when I type tox it runs both unit and functional (tox conditionals) tests.鉴于下面这个简化的 tox 文件,当我输入tox它会同时运行单元和功能(tox 条件)测试。

However I wish to test different python versions (3.7, 3.8, 3.9 etc.) and when I type tox -e py38 , it does not run unit and functional tests.但是,我希望测试不同的 Python 版本( tox -e py38等),并且当我输入tox -e py38 ,它不会运行单元和功能测试。

Is there a way to configure tox.ini such that when I type tox -e py38 it runs every conditional test?有没有办法配置 tox.ini 以便当我输入tox -e py38它会运行每个条件测试?

Note: tox -e py38-unit-functional is not what I am looking for.注意: tox -e py38-unit-functional不是我要找的。 I have an isolated CI environment calling the tox commands with tox -e py38 and in the project and when I add/delete/update new tox conditionals I don't want to update the CI scrips each time.我有一个隔离的 CI 环境,在项目中使用tox -e py38调用 tox 命令,当我添加/删除/更新新的 tox 条件时,我不想每次都更新 CI 脚本。 There are multiple projects that are using the same CI scripts.有多个项目使用相同的 CI 脚本。 Each project has different set of conditionals and they are subject to change.每个项目都有不同的条件集,它们可能会发生变化。 I want to be able to tell tox to run all conditionals.我希望能够告诉 tox 运行所有条件。

envlist =
    py3-{unit,functional}

[testenv]
basepython=python
whitelist_externals = make
commands =
    make clean
    unit: pytest unit
    functional: pytest functional

I couldn't find a way of doing it in the tox documentation.我在 tox 文档中找不到这样做的方法。 I am looking forward to your answers.我期待着您的回答。 If this is not possible with tox, it would still be informative to know.如果这对 tox 来说是不可能的,那么了解它仍然是有益的。 Thanks in advance提前致谢

Edit (clarity): In general I would like to avoid typing the names of all conditionals eg "unit", "functional", "acceptance", "performance" etc. Any other solution that allows me to run all of them without typing the conditional names and enabling me to specify the python version (eg py3.8) is very much appreciated.编辑(清晰):一般来说,我希望避免输入所有条件的名称,例如“单元”、“功能”、“接受”、“性能”等。任何其他允许我在不输入条件的情况下运行所有​​条件的解决方案非常感谢使用条件名称并使我能够指定 python 版本(例如 py3.8)。

The standalone tox command with no arguments will always run all environments specified in envlist - so if you want to run different Python versions with this command, you need to specify them:没有参数的独立tox命令将始终运行envlist指定的所有环境 - 因此,如果您想使用此命令运行不同的 Python 版本,则需要指定它们:

envlist = py{38,39}-{unit,functional}

That is usually a good idea, as you can use the envlist to run the tests in CI, too.这通常是个好主意,因为您也可以使用envlist在 CI 中运行测试。

If you want to manually select several Python versions, you could add more to the -e option by separating additional environments with a comma.如果您想手动选择多个 Python 版本,您可以通过用逗号分隔其他环境来向-e选项添加更多内容。

tox -e py37-unit,py38-unit,py37-functional,py38-functional

This command is certainly not very easy to type.这个命令肯定不是很容易输入。

PS: This is not exactly an answer to your problem, but you should think about whether you should run tox in CI instead of tox -e py38 . PS:这不完全是您问题的答案,但是您应该考虑是否应该在 CI 中运行tox而不是tox -e py38

I will give a talk at tomorrows's PyOhio about how to setup CI with tox (amongst others).我将在明天的 PyOhio 上发表演讲,讨论如何使用 tox (以及其他) 设置 CI

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

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