简体   繁体   中英

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.

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.

Is there a way to configure tox.ini such that when I type tox -e py38 it runs every conditional test?

Note: tox -e py38-unit-functional is not what I am looking for. 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. There are multiple projects that are using the same CI scripts. 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.

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. I am looking forward to your answers. If this is not possible with tox, it would still be informative to know. 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.

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:

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.

If you want to manually select several Python versions, you could add more to the -e option by separating additional environments with a comma.

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 .

I will give a talk at tomorrows's PyOhio about how to setup CI with tox (amongst others).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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