How to import all the environment variables in tox

前端 未结 1 2037
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 20:13

I\'m using following in setenv to import the environment variable from where I run, but is there a way to import all the variables so that I don\'t really need to import one

1条回答
  •  醉梦人生
    2021-01-03 20:40

    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!
    

    0 讨论(0)
提交回复
热议问题