[TIP] RFC: tox-2.0 to restrict/isolate env variables in test runs
holger at merlinux.eu
Sun Apr 19 01:12:20 PDT 2015
On Sun, Apr 19, 2015 at 09:41 +0200, Julian Berman wrote:
> Awesome +0.99 think this sounds great to me.
> The only thing that I would like personally I think is that the behavior
> for PYTHON envvars to not be cleared, for them to either persist by default
> as well or for appropriate defaults for tests be set (in some ways it's the
> test runner's responsibility to do the latter IMO but not all of them do so
> E.g. for reasons I haven't spent time deciphering, current tox unsets
> PYTHONDONTWRITEBYTECODE, which is pretty annoying (there's a comment about
> legacy something or other). I'd probably expect all of those envvars to
> persist or say in the case of PYTHONWARNINGS to be set to a more test
> suitable value like `default`.
I agree python-interpreter variables are a little special. tox at least
itself controls PYTHONHASHSEED FWIW (to allow test run repetition for
dict-ordering dependent bugs) and interferes indeed with
PYTHONDONTWRITEBYTECODE probably for reasons predating py27.
For PYTHONDONTWRITEBYTECODE and PYTHONWARNINGS, tox-2.0 could avoid any
special treatment and leave it to tox.ini (and maybe new command line
"--passenv", "--setenv" options?) to specify their handling. They would
otherwise remain unset as i think it's important to not have silent
> On Apr 19, 2015 9:31 AM, "holger krekel" <holger at merlinux.eu> wrote:
> > Hi tox users,
> > for tox-2.0 i'd like to introduce environment variable isolation. The
> > idea is that only a minimal default set of environment variables is
> > transferred to the test environment in contrast to the tox<2.0 where
> > all environment variables are copied to the test run. With tox-2.0 one
> > can thus make sure tests don't depend on random env variables but only
> > those which are specified with tox.ini.
> > If you want to transfer any other variables you'd have to use a new
> > "passenv"
> > setting. For example to pass through the content of LANG (used for locale
> > settings)
> > and typical home-directory settings (on win32 and unix):
> > [testenv]
> > passenv = LANG HOME HOMEDIR HOMEDRIVE
> > If an env variable does not exist it is ignored, remains unset in the test
> > run.
> > This allows to uncover hidden envvar dependencies and explicitely control
> > them.
> > FYI you can today already use the "setenv" option to specify env vars::
> > [testenv]
> > setenv =
> > MYENV = somesetting
> > But there is no way to prevent/exclude env variables to be copied to the
> > test run
> > from the environment variable set with which you invoke tox.
> > For a somewhat smoother transition it might make sense to default to the
> > old behaviour (transfer all env variables) with tox-2.0.X and assume
> > passenv
> > transfers all variables via a default "*" setting but issue a warning
> > and with tox-2.1 then default to an empty passenv setting.
> > comments welcome,
> > holger
> > --
> > about me: http://holgerkrekel.net/about-me/
> > contracting: http://merlinux.eu
> > _______________________________________________
> > testing-in-python mailing list
> > testing-in-python at lists.idyll.org
> > http://lists.idyll.org/listinfo/testing-in-python
about me: http://holgerkrekel.net/about-me/
More information about the testing-in-python