How to import all the environment variables in tox

牧云@^-^@ 提交于 2019-12-03 22:21:54

You can use passenv. If you pass the catch all wildcard * you have access to all environment variables from the parent environment:

passenv=SPACE-SEPARATED-GLOBNAMES

New in version 2.0.

A list of wildcard environment variable names which shall be copied from the tox invocation environment to the test environment when executing test commands. If a specified environment variable doesn’t exist in the tox invocation environment it is ignored. You can use * and ? to match multiple environment variables with one name.

minimal tox.ini to reproduce (no project necessary):

[tox]
skipsdist = True

[testenv]
passenv = *
skip_install = True
commands = python -c "print('computer says {env:MY_FANCY_ENV_VAR:}!')"

invocation in linux/unix shell:

MY_FANCY_ENV_VAR=no tox -qq

invocation on Windows cmd.exe:

set MY_FANCY_ENV_VAR=no & tox -qq

output:

computer says no!
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!