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 when formatting pytest --log-format argument #65

Closed
wwuck opened this issue Jun 24, 2021 · 1 comment · Fixed by #66
Closed

Error when formatting pytest --log-format argument #65

wwuck opened this issue Jun 24, 2021 · 1 comment · Fixed by #66
Labels
bug Something isn't working

Comments

@wwuck
Copy link
Contributor

wwuck commented Jun 24, 2021

Running tox-ini-fmt 0.5.0 on the following tox.ini file gives an error:

[testenv:pytest]
commands = pytest \
           --numprocesses=auto \
           --open-files \
           --cov=my_project \
           --cov-report=xml \
           --junitxml=junit-{envname}.xml \
           --log-format='%(asctime)s %(levelname)s %(message)s' \
           --log-date-format='%Y-%m-%d %H:%M:%S' \
           --log-cli-level='INFO' \
           {posargs}
# Install testenv requirements
deps = pytest
       pytest-antilru
       pytest-cov
       pytest-openfiles
       pytest-randomly
       pytest-xdist[psutil]
$ tox-ini-fmt tox.ini
Traceback (most recent call last):
  File "/home/devuan/.pyenv/versions/venv/bin/tox-ini-fmt", line 8, in <module>
    sys.exit(run())
  File "/home/devuan/.pyenv/versions/3.9.5/envs/venv/lib/python3.9/site-packages/tox_ini_fmt/__main__.py", line 26, in run
    formatted = format_tox_ini(opts.tox_ini, opts)
  File "/home/devuan/.pyenv/versions/3.9.5/envs/venv/lib/python3.9/site-packages/tox_ini_fmt/formatter/__init__.py", line 22, in format_tox_ini
    order_sections(parser, opts.pin_toxenvs)
  File "/home/devuan/.pyenv/versions/3.9.5/envs/venv/lib/python3.9/site-packages/tox_ini_fmt/formatter/section_order.py", line 20, in order_sections
    sections[section] = dict(parser[section])
  File "/home/devuan/.pyenv/versions/3.9.5/lib/python3.9/configparser.py", line 1255, in __getitem__
    return self._parser.get(self._name, key)
  File "/home/devuan/.pyenv/versions/3.9.5/lib/python3.9/configparser.py", line 799, in get
    return self._interpolation.before_get(self, section, option, value,
  File "/home/devuan/.pyenv/versions/3.9.5/lib/python3.9/configparser.py", line 395, in before_get
    self._interpolate_some(parser, option, L, value, section, defaults, 1)
  File "/home/devuan/.pyenv/versions/3.9.5/lib/python3.9/configparser.py", line 434, in _interpolate_some
    raise InterpolationMissingOptionError(
configparser.InterpolationMissingOptionError: Bad value substitution: option 'commands' in section 'testenv:pytest' contains an interpolation key 'asctime' which is not a valid option name. Raw value: "pytest \\\n--numprocesses=auto \\\n--open-files \\\n--cov=my_project \\\n--cov-report=xml \\\n--junitxml=junit-{envname}.xml \\\n--log-format='%(asctime)s %(levelname)s %(message)s' \\\n--log-date-format='%Y-%m-%d %H:%M:%S' \\\n--log-cli-level='INFO' \\\n{posargs}"
@gaborbernat
Copy link
Member

A PR to fix this would be welcomed 👍

@gaborbernat gaborbernat added the bug Something isn't working label Jun 24, 2021
gaborbernat pushed a commit that referenced this issue Jun 25, 2021
* Don't try to interpolate values in config

Fixes #65

* Add tests for configparser interpolation

Fixes #65

Signed-off-by: wwuck <wirelessduck@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants