Tox: Allow user configuration outside of tox.ini

Created on 17 Sep 2016  路  6Comments  路  Source: tox-dev/tox

I would like to override the "toxworkdir" config option without editing a project's tox.ini. As far as I can tell, there's no mechanism to allow me to do this.

It should probably be possible to specify additional config files somehow.

configuration type

All 6 comments

Original comment by @hpk42

right, i meant it this way :)

However, i am a bit hard pressed with spending much time on tox. Hope you and others continue to help with things :)

Original comment by @msabramo

The conftest.py mechanism in pytest is super useful. I wonder if tox could have a similar mechanism? conftox.py?

Hmmm, you called your file that too - maybe you had the same idea? :-)

Original comment by @hpk42

I agree it'd be useful to "enhance" tox config from a) a user-specific file b) from the command line. If it happens, tox should report it explicitely. As to a) we might also think about introducing a plugin mechanism so that e.g. $HOME/.tox/conftox.py is read and can define hooks that tox calls (similar to pytest is extended through tox).

Original comment by @msabramo

Yeah, in the past, I've sometimes wished that there were a ~/.tox/tox.config or something.

My use case is that I love having pdbpp or ipdb or whatever debugging tools present in my tox virtualenvs so that if the tests fail, I have some nice tools already present for debugging. In the past, I have done one of these:

  1. Manually install tool -- e.g.: .tox/py27/bin/pip install pdbpp -- this is tedious and has to be repeated if the virtualenv gets rebuilt.
  2. Add it to tox.ini for project. This is mostly okay but sometimes others have (rightfully) complained that I'm adding unnecessary dependencies that could break the tests or increase the time to run the tests, so I shouldn't be adding my own personal favorites.

So I have sometimes wished that I could have a user configuration that allows me to tell tox to install these tools in every virtualenv it creates. The one gotcha with this is that if abused, people can have a build that works in one person's environment but not another's because they've put necessary deps in their user config. One thing to help with this is an option that tells tox not to use the user config. Hopefully, people would periodically run without the user config to make sure stuff works without any user config.

The user config might also be a good place to put alternative index servers. We have an internal indexserver for our company and it's referenced in the tox.ini of tens of different projects. Not so DRY.

I stumbled over this issue searching for a solution to provide the basepython for each testenv on different windows machines. I came up with a very simple tox plugin which loads an additional config file from $HOME derectory and extends / overwrites the different testenv configurations using the tox_configure hook.

If anyone is interested I can publish this plugin.

I would say that this is nowadays possible by using environment variable substitutions - no extra configuration necessary, or am I am missing something?

Was this page helpful?
0 / 5 - 0 ratings