Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posargs can't be found except in very specific ways, is not curently documented either #307

Closed
pytoxbot opened this issue Sep 17, 2016 · 4 comments

Comments

@pytoxbot
Copy link

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.

@pytoxbot
Copy link
Author

Original comment by aostr123

Add test for issue #307

This adds a test to address the second example in issue #307, the
first example is already addressed.

Closes issue #307

→ <<cset 62c553e32ce9>>

@pytoxbot
Copy link
Author

Original comment by @nakato

Example 1 is the same as #279.

Example 2 is fixed by #279, and I'll add a test for that.
PR#195

@pytoxbot
Copy link
Author

Original comment by @zzzeek

it looks pretty similar, though my test case is different; #279 is attempting to move {posargs} as part of a variable that's interpreted elsewhere, while mine is doing something simpler, adding {posargs} in place to a line that happens to include variables from elsewhere. While the fix for both might be the same I'd hope that all of these combinations are tested.

@pytoxbot
Copy link
Author

Original comment by @sigmavirus24

This looks to be a duplicate of #279

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant