Skip to content

log_cli_level does not accept an integer #14253

@stdedos

Description

@stdedos
  • a detailed description of the bug or problem you are having
  • [-] output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

According to the documentation https://docs.pytest.org/en/stable/reference/reference.html#confval-log_cli_level

The integer value or the names of the levels can be used.

However, setting

[tool.pytest]
log_cli = true
log_cli_level = 0

causes

$ pytest -k test_timeout
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/_pytest/main.py", line 314, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 1159, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 534, in call_historic
INTERNALERROR>     res = self._hookexec(self.name, self._hookimpls.copy(), kwargs, False)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR>     raise exception
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/_pytest/logging.py", line 638, in pytest_configure
INTERNALERROR>     config.pluginmanager.register(LoggingPlugin(config), "logging-plugin")
INTERNALERROR>                                   ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/_pytest/logging.py", line 689, in __init__
INTERNALERROR>     self.log_cli_level = get_log_level_for_setting(
INTERNALERROR>                          ^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/_pytest/logging.py", line 616, in get_log_level_for_setting
INTERNALERROR>     log_level = config.getini(setting_name)
INTERNALERROR>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 1662, in getini
INTERNALERROR>     self._inicache[canonical_name] = val = self._getini(canonical_name)
INTERNALERROR>                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 1706, in _getini
INTERNALERROR>     return self._getini_toml(name, canonical_name, type, value, default)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "~/p/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 1847, in _getini_toml
INTERNALERROR>     raise TypeError(
INTERNALERROR> TypeError: ~/p/pyproject.toml: config option 'log_cli_level' expects a string, got int: 0

pytest 9.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions