我想将默认值设置为tox中缺少的环境变量,但前提是它们缺失。
答案 0 :(得分:2)
这可以通过env substitution运行。使用TOX_WORKDIR
或默认值的示例:
tox.ini
[tox]
envlist = py
skipsdist = true
[testenv]
setenv = TOX_WORKDIR = {env:TOX_WORKDIR:.tox}
commands = python ./envecho.py
envecho.py
#!/usr/bin/env python
import os
print(os.getenv("TOX_WORKDIR"))
$ tox
py create: /home/oliver/Dropbox/projects/tox/lab/mini/.tox/py
py installed: appdirs==1.4.3,packaging==16.8,pyparsing==2.2.0,six==1.10.0
py runtests: PYTHONHASHSEED='2704413679'
py runtests: commands[0] | python ./envecho.py
.tox
______________________________ summary ______________________________
py: commands succeeded
congratulations :)
$ TOX_WORKDIR=/tmp/ tox
py installed: appdirs==1.4.3,packaging==16.8,pyparsing==2.2.0,six==1.10.0
py runtests: PYTHONHASHSEED='30398946'
py runtests: commands[0] | python ./envecho.py
/tmp/
______________________________ summary ______________________________
py: commands succeeded
congratulations :)