运行 tox 具有不同的环境变量配置
Running tox with different environment variable config
我想 运行 使用不同的环境变量值进行测试。我有这个 tox.ini,它不符合我的要求:
# tox.ini
[tox]
envlist = py37-{foo,bar}
[testenv]
description = Tests common
setenv =
MY_VAR=COMMON
commands =
env
[testenv:foo]
description = Tests foo
setenv =
MY_VAR=FOO
[testenv:bar]
description = Tests bar
setenv =
MY_VAR=BAR
以上 ini
产生了以下输出:
$ tox
GLOB sdist-make:
***
py37-foo run-test: commands[0] | env
***
MY_VAR=COMMON <<<--- MY_VAR=foo is expected
***
py37-bar run-test: commands[0] | env
***
MY_VAR=COMMON <<<--- MY_VAR=bar is expected
怎么了?
我使用:
- 赢得 10.0.18363 构建 18363
- Python 3.7.4
- 毒素:3.14.0
tox
不组合环境。每个环境都源自 [testenv]
,但不考虑包含其他环境。你必须在 tox.ini
中自己组合它们。这应该有效:
[tox]
envlist = py37-{foo,bar}
[testenv]
description = Tests common
setenv =
MY_VAR=COMMON
commands =
env
[foo]
description = Tests foo
setenv =
MY_VAR=FOO
[bar]
description = Tests bar
setenv =
MY_VAR=BAR
[testenv:py37-foo]
description = Tests py37 foo
setenv = {[foo]setenv}
[testenv:py37-bar]
description = Tests py37 bar
setenv = {[bar]setenv}
关键是Compressing dependency matrix。该技术产生紧凑且非冗余的解决方案:
[tox]
envlist = py37-{foo,bar,baz}
[testenv]
setenv =
MY_VAR=COMMON
foo: MY_VAR=FOO
bar: MY_VAR=BAR
commands =
env
我想 运行 使用不同的环境变量值进行测试。我有这个 tox.ini,它不符合我的要求:
# tox.ini
[tox]
envlist = py37-{foo,bar}
[testenv]
description = Tests common
setenv =
MY_VAR=COMMON
commands =
env
[testenv:foo]
description = Tests foo
setenv =
MY_VAR=FOO
[testenv:bar]
description = Tests bar
setenv =
MY_VAR=BAR
以上 ini
产生了以下输出:
$ tox
GLOB sdist-make:
***
py37-foo run-test: commands[0] | env
***
MY_VAR=COMMON <<<--- MY_VAR=foo is expected
***
py37-bar run-test: commands[0] | env
***
MY_VAR=COMMON <<<--- MY_VAR=bar is expected
怎么了?
我使用:
- 赢得 10.0.18363 构建 18363
- Python 3.7.4
- 毒素:3.14.0
tox
不组合环境。每个环境都源自 [testenv]
,但不考虑包含其他环境。你必须在 tox.ini
中自己组合它们。这应该有效:
[tox]
envlist = py37-{foo,bar}
[testenv]
description = Tests common
setenv =
MY_VAR=COMMON
commands =
env
[foo]
description = Tests foo
setenv =
MY_VAR=FOO
[bar]
description = Tests bar
setenv =
MY_VAR=BAR
[testenv:py37-foo]
description = Tests py37 foo
setenv = {[foo]setenv}
[testenv:py37-bar]
description = Tests py37 bar
setenv = {[bar]setenv}
关键是Compressing dependency matrix。该技术产生紧凑且非冗余的解决方案:
[tox]
envlist = py37-{foo,bar,baz}
[testenv]
setenv =
MY_VAR=COMMON
foo: MY_VAR=FOO
bar: MY_VAR=BAR
commands =
env