Some of my tests only run under Linux, but others run everywhere. I'd like to set the minimum coverage variable to a higher value when running on Linux, than when running on my desktop Mac.
How can I do that?
Here's a bit of my tox.ini:
[tox]
MINCOVERAGE = 35
envlist = py37
[testenv]
commands =
pytest -v -v -x --fulltrace --tb=long --showlocals \
--cov={envsitepackagesdir}/secretsapi --cov-report=html --no-cov-on-fail \
--cov-fail-under={[tox]MINCOVERAGE} mypackage/tests
I'd like to set MINCOVERAGE to 70 when on Linux, and 35 when on other platforms.
How can I do that?
You can define OS-specific environments and set an environment variable with different value for each OS:
[tox]
envlist = py37-{linux,mac,win}
[testenv]
platform =
linux: linux
mac: darwin
win: win32
deps =
pytest
pytest-cov
setenv =
MINCOVERAGE = 35 # default for mac, win
linux: MINCOVERAGE = 70 # special for linux
commands =
pytest ... --cov-fail-under={env:MINCOVERAGE}
Reference in tox
docs, as pointed out by @sinoroc in the comments: Platform specification.