From 20d5b4e384e812a64b547220f7341c6004c602e5 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 6 Feb 2018 23:17:40 +0100 Subject: [PATCH] Update pytest log handling In pytest 3.4, we now need to explicitly set the log level and caplog.at_level now sets the level of the root handler. --- pytest.ini | 1 + tests/helpers/logfail.py | 12 +----------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/pytest.ini b/pytest.ini index 4fefa0f77..56cd808ad 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,5 @@ [pytest] +log_level = NOTSET addopts = --strict -rfEw --faulthandler-timeout=90 --instafail --pythonwarnings error --benchmark-columns=Min,Max,Median testpaths = tests markers = diff --git a/tests/helpers/logfail.py b/tests/helpers/logfail.py index 8eee34911..740dd4333 100644 --- a/tests/helpers/logfail.py +++ b/tests/helpers/logfail.py @@ -22,7 +22,6 @@ import logging import pytest -import _pytest.logging class LogFailHandler(logging.Handler): @@ -40,17 +39,8 @@ class LogFailHandler(logging.Handler): if logger.name == 'messagemock': return - for h in root_logger.handlers: - if isinstance(h, _pytest.logging.LogCaptureHandler): - capture_handler = h - break - else: - # The LogCaptureHandler is not available anymore during fixture - # teardown, so we ignore logging messages emitted there.. - return - if (logger.level == record.levelno or - capture_handler.level == record.levelno): + root_logger.level == record.levelno): # caplog.at_level(...) was used with the level of this message, # i.e. it was expected. return