python – 环境变量
作者:互联网
我有一个像这样的tox.ini文件:
[tox]
envlist =
{py27,py34}
[testenv]
setenv =
PYTHONDONTWRITEBYTECODE=1
deps =
-r{toxinidir}/requirements-test.txt
commands =
nosetests -v --stop --with-coverage --cover-package=project
所以,我需要从我的SO传递给我的tox env环境变量.此变量是私有的,并根据环境而变化.
我是怎么做到的
解决方法:
我找到了解决方案! Tox 2.0有一个名为passenv的设置
A list of wildcard environment variable names which shall be copied from the tox invocation environment to the test environment. 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.
Note that the PATH and PIP_INDEX_URL variables are unconditionally passed down and on Windows SYSTEMROOT, PATHEXT, TEMP and TMP will be passed down as well whereas on unix TMPDIR will be passed down. You can override these variables with the setenv option.
标签:python,virtualenv,tox 来源: https://codeday.me/bug/20190702/1359546.html