Beware of emacs pytest runner defaults
Emacs provides an incredible python developer experience.
One of it many features is the ability to run pytest.
However, I spent a reasonable amount of time, figuring out why M-x python-test-one
was ignoring my pytest log level settings in pyproject.toml.
Whatever I set in pyproject.toml, M-x python-test-one
was printing out any level e.g. logger.INFO("do not show in test")
[tool.pytest.ini_options]
log_cli_level = "Error"
The solution was to remove the -s
flag from pytest-cmd-flags “-x -s”.
Add this line to your init.el:
'(pytest-cmd-flags "-x")
Now your pytest buffer shows the log at it’s appropriate level.