tox 1.4.3 {[section]name} substitution does not work in general

Issue #97 on hold
Krisztian Fekete created an issue

I am trying to reuse tox.ini with minimal changes between projects/packages - the only variation is in deps and the project/package name (see package section below). I want commands to be the same, so I tried to define an ini variable for package name and reference it from commands without success:


name = whatever
deps =
    # package specific dependencies


envlist = py27


deps =

    # needed by commands

commands =
    coverage erase
    coverage run {envbindir}/nosetests
    coverage report --show-missing --include={[package]name}/*
    pyflakes {[package]name}
    pep8 {[package]name}

I get tox.ConfigError: ConfigError: substitution key '[package]name' not found with this config.

It looks like the ini reading is restricted to known keys only ({[package]deps} in [testenv]deps works!), so it is currently not possible to introduce & reference new, unknown-to-tox, keys.

A potentially related issue is #38 {[section]name} subsitution does not work for commands

Comments (7)

  1. Holger Krekel repo owner

    yes, the config parsing needs to be generalized. Do you feel like giving it a stab?

  2. Kevin Phillips

    I'm not sure if this improvement was completed or not, however in case anyone is interested I found a simple workaround to this limitation - at least for the limited use case described here. Consider the following snippet:

    setenv = TOX_PACKAGE_NAME=mypackage
    commands = pylint {env:TOX_PACKAGE_NAME}

    By defining your desired parameters as environment variables, taking care to name them such that they don't conflict with any other vars in your build environment, you can then use the TOX environment variable substitution to refer to the values.

    This might not work for the general case but should be workable for those simple cases like this one.

  3. Log in to comment