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

Error while parsing tox.ini with {posargs: tests} after line continuation #437

Closed
lopuhin opened this issue Jan 16, 2017 · 3 comments
Closed
Labels
area:documentation bug:minor does not affect many people or has no big impact level:easy rought estimate that this might be quite easy to implement pr-merged
Milestone

Comments

@lopuhin
Copy link

lopuhin commented Jan 16, 2017

Here is an example tox.ini that triggers the error (edit: extra space after "posargs:" is important):

[tox]
envlist = py27

[testenv]
deps=
    pytest

commands=
    py.test --doctest-modules \
        {posargs: tests}

Running tox results in the following error:

$ tox
Traceback (most recent call last):
  File "toxvenv/bin/tox", line 11, in <module>
    sys.exit(cmdline())
  File "toxvenv/lib/python3.5/site-packages/tox/session.py", line 38, in main
    config = prepare(args)
  File "toxvenv/lib/python3.5/site-packages/tox/session.py", line 26, in prepare
    config = parseconfig(args)
  File "toxvenv/lib/python3.5/site-packages/tox/config.py", line 239, in parseconfig
    parseini(config, inipath)
  File "toxvenv/lib/python3.5/site-packages/tox/config.py", line 760, in __init__
    self.make_envconfig(name, section, reader._subs, config)
  File "toxvenv/lib/python3.5/site-packages/tox/config.py", line 791, in make_envconfig
    res = meth(env_attr.name, env_attr.default)
  File "toxvenv/lib/python3.5/site-packages/tox/config.py", line 964, in getargvlist
    return _ArgvlistReader.getargvlist(self, s)
  File "toxvenv/lib/python3.5/site-packages/tox/config.py", line 1140, in getargvlist
    (reader.section_name, "commands"))
tox.ConfigError: ConfigError: line-continuation ends nowhere while resolving for [testenv:py27] commands

pip list output:

pip (9.0.1)
pluggy (0.4.0)
py (1.4.32)
setuptools (18.2)
tox (2.5.0)
virtualenv (15.1.0)

If line continuation is placed in a different place, for example:

commands=
    py.test \
        --doctest-modules {posargs: tests} 

everything is fine.

@speedyleion
Copy link

It looks like the culprit is SectionReader._apply_factors in config.py
This nested function appears to be looking for lines like py{27,35}: my command and interprets the {posargs: tests} as a {posargs factor with a tests} command.

        def factor_line(line):
            m = re.search(r'^([\w{}\.,-]+)\:\s+(.+)', line)
            if not m:
                return line

            expr, line = m.groups()
            if any(fs <= self.factors for fs in _split_factor_expr(expr)):
                return line

The example here, http://tox.readthedocs.io/en/latest/config.html#substitutions-for-positional-arguments-in-commands shows no space between the posargs and the substitution which works if you do {posargs:tests}.

More of an FYI as I have no idea what the maintainers design intent is.

@lopuhin
Copy link
Author

lopuhin commented Jan 19, 2017

@speedyleion thanks for the update: indeed, it only fails to parse if an extra space is present after "posargs:", without it it's possible to place line continuation at any place. So I'll be using it without space now, as in the docs :) In my defence, it works even with a space, but this makes the issue super minor.

@obestwalter
Copy link
Member

Thanks @lopuhin for reporting this and @speedyleion for checking the code and the docs. Atm I would interpret it as a documentation bug for making it not clear enough that a space is not allowed after the colon.

@obestwalter obestwalter added area:documentation level:easy rought estimate that this might be quite easy to implement bug:minor does not affect many people or has no big impact and removed bug labels Sep 4, 2017
@gaborbernat gaborbernat added this to the 3.5 milestone Sep 18, 2018
@gaborbernat gaborbernat modified the milestones: 3.5, 3.6 Oct 8, 2018
@helpr helpr bot added the pr-available label Oct 13, 2018
@helpr helpr bot added pr-merged and removed pr-available labels Oct 13, 2018
@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
area:documentation bug:minor does not affect many people or has no big impact level:easy rought estimate that this might be quite easy to implement pr-merged
Projects
None yet
Development

No branches or pull requests

4 participants