commands substitution does not work if commands uses '{posargs}'

Issue #279 on hold
Sachi King created an issue
[testenv:sect1]
commands = something {posargs}

[testenv:sect2]
commands = {[testenv:sect1]commands}

$  tox -e sect2

  File "/usr/bin/tox", line 9, in <module>
    load_entry_point('tox==2.1.1', 'console_scripts', 'tox')()
  File "/usr/lib/python3.5/site-packages/tox/session.py", line 38, in main
    config = prepare(args)
  File "/usr/lib/python3.5/site-packages/tox/session.py", line 26, in prepare
    config = parseconfig(args)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 219, in parseconfig
    parseini(config, inipath)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 669, in __init__
    self.make_envconfig(name, section, reader._subs, config)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 697, in make_envconfig
    res = meth(env_attr.name, env_attr.default)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 864, in getargvlist
    return _ArgvlistReader.getargvlist(self, s)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 1013, in getargvlist
    replaced = reader._replace(current_command)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 982, in _replace
    return RE_ITEM_REF.sub(self._replace_match, x)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 978, in _replace_match
    return handler(match)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 948, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 937, in _substitute_from_other_section
    return self._replace(x)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 982, in _replace
    return RE_ITEM_REF.sub(self._replace_match, x)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 978, in _replace_match
    return handler(match)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 948, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 942, in _substitute_from_other_section
    "substitution key %r not found" % key)
tox.ConfigError: ConfigError: substitution key 'posargs' not found

Comments (8)

  1. Boris Burkov Account Deactivated

    I've tried the following tox.ini with both tox 1.7.0 and tox 2.3.0 and both result in

    Traceback (most recent call last):
      File "/usr/local/bin/tox", line 11, in <module>
        sys.exit(cmdline())
      File "/usr/local/lib/python2.7/dist-packages/tox/session.py", line 38, in main
        config = prepare(args)
      File "/usr/local/lib/python2.7/dist-packages/tox/session.py", line 26, in prepare
        config = parseconfig(args)
      File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 229, in parseconfig
        parseini(config, inipath)
      File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 729, in __init__
        self.make_envconfig(name, section, reader._subs, config)
      File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 764, in make_envconfig
        res = reader.getlist(env_attr.name, sep="\n")
      File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 882, in getlist
        s = self.getstring(name, None)
      File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 949, in getstring
        x = self._replace(x, name=name, crossonly=crossonly)
      File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 973, in _replace
        return Replacer(self, crossonly=crossonly).do_replace(value)
      File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 992, in do_replace
        return self.RE_ITEM_REF.sub(self._replace_match, x)
      File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 1021, in _replace_match
        return self._replace_substitution(match)
      File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 1067, in _replace_substitution
        val = self._substitute_from_other_section(sub_key)
      File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 1061, in _substitute_from_other_section
        "substitution key %r not found" % key)
    tox.ConfigError: ConfigError: substitution key 'posargs' not found
    

    tox.ini:

    [tox]
    envlist=dj{18,19,110}-py{27,35}-me{09,010}
    
    [testenv]
    deps =
        -rrequirements_dev.txt
        dj18: Django==1.8.*
        dj19: Django==1.9.*
        dj110: Django==1.10.*
        djangorestframework==3.*
        blinker==1.*
        me09: mongoengine==0.9.*
        me09: pymongo==2.*
        me010: mongoengine==0.10.*
        me010: pymongo==3.*
        commands = ./runtests.py --nolint {posargs}
    
  2. Sachi King reporter

    2.3.0 was released before this patch.

    There is currently not a release with this patch in it.

  3. Boris Burkov Account Deactivated

    Sorry, I 've a bug in this config: commands = ./runtests.py --nolint {posargs} is underindented. I fixed indentation and it works now.

  4. Log in to comment