Skip to content

Cannot setup log_format in setup.cfg, because of InterpolationMissingOptionError` #3062

@prokher

Description

@prokher

I would like to setup log_format in the project-wise configuration file setup.cfg. I do it like this:

[tool:pytest]
log_format = %(filename)s:%(lineno)d %(name)s%(levelname)s%(message)s

Given this, any invocation of some setup.py or simply pip install -r requirements.txt in the directory where setup.cfg resides, gives me a error:

configparser.InterpolationMissingOptionError: Bad value substitution: option 'log_format' in section 'tool:pytest' contains an interpolation key 'filename' which is not a valid option name. Raw value: '%(filename)s:%(lineno)d %(name)s%(levelname)s%(message)s'

As far as I understand, the reason is that %-formatting is used in config files for string interpolation. It is recommended to screen % with another % to avoid interpolation. Well, if I do this then pytest-catchlog stops interpreting this string as format and simply output it as is.

It looks like, pytest-catchlog shall adopt the rules of writing setup.cfg files. If there is another solution or workaround, please let me know.
Bug was originally posted to the pytest-catchlog issue tracker here , but once this plugin was merged into PyTest I have to report the bug is still here.

P.S. Sorry for ignoring all the steps listed in the contributing guidelines, but this bug was reproduced and confirmed successfully in the original bug report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: loggingrelated to the logging builtin plugintype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions