4

I have a tox.ini file like this:

[tox]
envlist =
    {py27,py34}

[testenv]
setenv =
    PYTHONDONTWRITEBYTECODE=1
deps =
    -r{toxinidir}/requirements-test.txt
commands =
    nosetests -v --stop --with-coverage --cover-package=project

So, I need to pass to my tox env an environment variable from my SO. This variable is private and changes according to the environment.

How I do it?

12
  • Could you let us know what you've tried so far? Jun 15, 2015 at 1:09
  • @GavinSchulz I try: [testenv] setenv = VAR=$VAR Jun 15, 2015 at 1:18
  • Did you try: ENV="foo" tox? Jun 15, 2015 at 1:38
  • @JamesMills I need to run this on Travis too, so, this approach doesn't work. Jun 15, 2015 at 1:42
  • @JamesMills I try your suggestion locally, but doesn't work. Jun 15, 2015 at 1:51

1 Answer 1

2

I found the solution! Tox 2.0 has a settings called 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.

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.