[TIP] designing ways for tox to inherit dependencies and other parts of the environment configuration

holger krekel holger at merlinux.eu
Mon Nov 14 04:16:50 PST 2011


Hi Ronny, all interested in tox config/parametrization,

i agree that some way to reduce tox.ini boilerplate definitions and
especially deps would be nice.   One reference is from Alex Gaynor
some time ago where he asks for ways to reduce tox config boilerplate 
in his project: https://github.com/alex/django-taggit/blob/master/tox.ini

I'd like to onsider a new {}-style substitution code which
would transform your example like this:

    [testenv]
    commands=...
    deps=pytest
        pytest-cov

    [testenv:foo-12]
    deps=
        {testenv:deps}   # inline section [testenv]'s deps var
        foo==1.2

    [testenv:foo-13]
    deps=
        {testenv:deps}
        foo==1.3

The main difference to your suggestions is:

- the mechanism could naturally extend to other config bits
- there is control over when a variable is inlined (not important
  for deps probably but for other bits)

best,
holger




> [testenv:foo-13]
> deps=
>    pytest
>    pytest-cov
>    foo==1.3

(see http://tox.testrun.org/en/latest/config.html#substitutions for current subsitutions):





On Tue, Nov 01, 2011 at 22:03 +0100, Ronny Pfannschmidt wrote:
> Hi,
> 
> since i got aware of quite a few people (including me)
> that are unhappy with the need of repetition in tox environment
> configurations,
> 
> we should come up with a good way to express commands/dependencies that
> are common
> 
> the first way i came up with, is a simple inherit key, that is processed
> before adding the data from the current section and adds dependency
> items from a "base section"
> 
> with its help something like
> 
> 
> ------------------
> [testenv]
> commands=...
> 
> [testenv:foo-12]
> deps=
>    pytest
>    pytest-cov
>    foo==1.2
> 
> [testenv:foo-13]
> deps=
>    pytest
>    pytest-cov
>    foo==1.3
> ....
> -----------------
> can be reduced to
> 
> -----------------
> [base:foo]
> deps=
>    pytest
>    pytest-cov
> 
> [testenv]
> commands=...
> inherit=foo
> 
> [testenv:foo-12]
> deps=foo==1.2
> 
> [testenc:foo-13]
> deps=foo==1.3
> 
> ...
> -----------------
> 
> another idea is to have something like
> 
> -----------------
> 
> [depsets]
> foo=
>    pytest
>    pytest-cov
> [testenv]
> depsets = foo
> ...
> 
> -----------------
> 
> I'm pretty sure there are still some conceptual issues in those
> approaches, thus i want to have a discussion on how to proceed
> 
> i already implemented the first outlined approach as proof of concept
> (without a way to debug the source of a dependency)
> 
> Regards,
> Ronny Pfannschmidt
> 



> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python




More information about the testing-in-python mailing list