We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If I pass logger name to caplog.set_level like this
caplog.set_level(logging.ERROR, logger='package.utils')
then for all following test cases that logger will have level set to ERROR, which is not expected.
The text was updated successfully, but these errors were encountered:
I've fixed that with the following custom fixture, please let me know if it worth a PR
import logging from pytest_catchlog import LogCaptureFixture class CustomLogCaptureFixture(LogCaptureFixture): def __init__(self, item, monkeypatch): super().__init__(item) self._monkeypatch = monkeypatch def set_level(self, level, logger=None): obj = logger and logging.getLogger(logger) or self.handler self._monkeypatch.setattr(obj, 'level', logging._checkLevel(level)) @pytest.fixture() def caplog(request, monkeypatch): """Custom caplog fixture that fixes set_level side effects""" return CustomLogCaptureFixture(request.node, monkeypatch)
Sorry, something went wrong.
@chekunkov Looks good at the first glance, thank you!
No branches or pull requests
If I pass logger name to caplog.set_level like this
then for all following test cases that logger will have level set to ERROR, which is not expected.
The text was updated successfully, but these errors were encountered: