Setting environment variable crashes with posargs

Issue #355 on hold
Oliver Bestwalter created an issue

On tox 2.4.0.dev1:

setenv =
    ; works
    TOX_ENVNAME = {envname}
    TOX_TOXINIDIR = {toxinidir}
    TOX_TOXWORKDIR = {toxworkdir}
    ; crashes
    TOX_POSARGS = {posargs}

It works with all other variables as far as I can say, only with posargs it crashes with

Traceback (most recent call last):
  File "/home/oliver/.pyenv/versions/avira/bin/tox", line 9, in <module>
    load_entry_point('tox', 'console_scripts', 'tox')()
  File "/home/oliver/work/pytest/tox/tox/", line 39, in main
    retcode = Session(config).runcommand()
  File "/home/oliver/work/pytest/tox/tox/", line 382, in runcommand
    return self.subcommand_test()
  File "/home/oliver/work/pytest/tox/tox/", line 547, in subcommand_test
  File "/home/oliver/work/pytest/tox/tox/", line 372, in _pcall
    env = self._getenv(testcommand=testcommand)
  File "/home/oliver/work/pytest/tox/tox/", line 314, in _getenv
  File "/home/oliver/work/pytest/tox/tox/", line 295, in __getitem__
    x = self.get(name, _dummy)
  File "/home/oliver/work/pytest/tox/tox/", line 289, in get
    self.resolved[name] = res = self.reader._replace(val)
  File "/home/oliver/work/pytest/tox/tox/", line 1010, in _replace
    return Replacer(self, crossonly=crossonly).do_replace(value)
  File "/home/oliver/work/pytest/tox/tox/", line 1029, in do_replace
    return self.RE_ITEM_REF.sub(self._replace_match, x)
  File "/home/oliver/work/pytest/tox/tox/", line 1058, in _replace_match
    return self._replace_substitution(match)
  File "/home/oliver/work/pytest/tox/tox/", line 1104, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/home/oliver/work/pytest/tox/tox/", line 1098, in _substitute_from_other_section
    "substitution key %r not found" % key)
tox.ConfigError: ConfigError: substitution key 'posargs' not found

Comments (5)

  1. Oliver Bestwalter reporter

    I just had a look in the code: posargs are treated differently from the other values which are called substitutions, that is why posargs does not turn up in the reader._subs dict, which is what is accessed, when setenv is being used. So I understand now, why the error occurs, but from my perspective as a user there is no reason, why {posargs} should behave differently than {envname} and why it shoud behave differently in setenv than somewhere else in tox.ini.

  2. Log in to comment