New issue 307: posargs can't be found except in very specific ways, is not 
curently documented either
https://bitbucket.org/hpk42/tox/issues/307/posargs-cant-be-found-except-in-very

Mike Bayer:

possibly related to #150, i can't use {posargs} even in "commands=" if any 
other substitution are present.

Using tox 2.3.1, and the commandline here is just to try to list the 
environments:

    $ tox -c some_tox.ini -l

For all examples, failure looks like:


```
#!

Traceback (most recent call last):
  File "/home/classic/.venv/bin/tox", line 11, in <module>
    sys.exit(cmdline())
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/session.py", line 
38, in main
    config = prepare(args)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/session.py", line 
26, in prepare
    config = parseconfig(args)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
229, in parseconfig
    parseini(config, inipath)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
729, in __init__
    self.make_envconfig(name, section, reader._subs, config)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
760, in make_envconfig
    res = meth(env_attr.name, env_attr.default)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
929, in getargvlist
    return _ArgvlistReader.getargvlist(self, s)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
1097, in getargvlist
    replaced = reader._replace(current_command)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
973, in _replace
    return Replacer(self, crossonly=crossonly).do_replace(value)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
992, in do_replace
    return self.RE_ITEM_REF.sub(self._replace_match, x)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
1021, in _replace_match
    return self._replace_substitution(match)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
1067, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
1058, in _substitute_from_other_section
    crossonly=self.crossonly)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
973, in _replace
    return Replacer(self, crossonly=crossonly).do_replace(value)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
992, in do_replace
    return self.RE_ITEM_REF.sub(self._replace_match, x)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
1021, in _replace_match
    return self._replace_substitution(match)
  File "/home/classic/.venv/lib/python2.7/site-packages/tox/config.py", line 
1067, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/home/classic/.venv/lib/python2.7/site-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

```

Example 1, fails:


```
#!

[tox]
envlist = 
py{26,27,34,35}-sqla_{cext,nocext}-db_{default,sqlitepg,mysql,oracle,mssql}

[testenv]
basecommand=
  python -m pytest -n4 --dropfirst  {posargs}

commands=
  db_{mysql}: {[testenv]basecommand} --db mysql --db pymysql


```

Example 2, fails:


```
#!

[tox]
envlist = 
py{26,27,34,35}-sqla_{cext,nocext}-db_{default,sqlitepg,mysql,oracle,mssql}

[testenv]
basecommand=
  python -m pytest -n4 --dropfirst

commands=
  db_{mysql}: {[testenv]basecommand} --db mysql --db pymysql {posargs}

```

Example 3, passes:


```
#!

[tox]
envlist = 
py{26,27,34,35}-sqla_{cext,nocext}-db_{default,sqlitepg,mysql,oracle,mssql}

[testenv]

commands=
  db_{mysql}: python -m pytest -n4 --dropfirst --db mysql --db pymysql {posargs}

```

it would be nice if {posargs} just worked everywhere.  

Also, current documentation at 
https://tox.readthedocs.org/en/latest/config.html does not describe the 
{posargs} token by itself, there's just the docs about {posargs:DEFAULT} which 
seems to be something else.


_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to