How to minimize repetition in a toxicity file

Objective: Successfully execute certain toxicity commands and only run "exactly" for that command.

Example: tox -e py35-integration

tox

should only run for py35 integration and does not include standard or standalone definition py35

.

I have tried two different approaches which I understand are two ways to try and do what I am trying to do.

  • Note that the command flake8

    is to easily isolate the various commands and tell me what works. This is not an indication of the command I am actually trying to run.

Also, ini files only display the relevant parts.

First approach

[tox]
envlist = {py27,py35}, {py27,py35}-integration

[testenv]
commands =
    py27: python -m testtools.run discover
    py35: python -m testtools.run discover
    py27-integration: flake8 {posargs}
    py35-integration: flake8 {posargs}

      

With this approach, the understanding here is that I want it to be tox -e py27-integration

executed without doing what is defined for the command py27

. This is not what is happening. Instead, it will run both py27

and py27-integration

.

Second approach

[tox]
envlist = {py27,py35}, {py27,py35}-integration

[testenv]
commands =
    python -m testtools.run discover

[testenv:integration]
commands = 
    flake8 {posargs}

      

Now I explicitly allocate an environment for "under" with its own command to run for "integration".

Unfortunately, however, I am greeted with the same behavior for all matching "py27" patterns.

I am trying to avoid repeating test structures like: [testenv:py27-integration]

and [testenv:py35-integration]

that contain precise definitions (the goal is to minimize repetition).

I would like to know if there is a way that I can achieve what I am trying to do.

I don't want to risk doing something like p27-integration

as an alternative naming scheme, as our CI pipelines have templates expecting certain naming structures, and those names are also idiomatic for toxicity, since py27

for example a 2.7 virtual environment setup is understood.

+3


source to share


1 answer


[tox]
envlist = {py27,py35}, {py27,py35}-integration

[testenv]
commands =
    python -m testtools.run discover

[integration]
commands = 
    flake8 {posargs}

[testenv:py27-integration]
commands = 
    {[integration]commands}

[testenv:py35-integration]
commands = 
    {[integration]commands}

      



If you need to change the integration commands, you change them in one place: in [integration]

.

0


source







All Articles