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.
This commit is contained in:
Florian Bruhin 2018-02-06 23:17:40 +01:00
parent 9eefbf24a2
commit 20d5b4e384
2 changed files with 2 additions and 11 deletions

View File

@ -1,4 +1,5 @@
[pytest] [pytest]
log_level = NOTSET
addopts = --strict -rfEw --faulthandler-timeout=90 --instafail --pythonwarnings error --benchmark-columns=Min,Max,Median addopts = --strict -rfEw --faulthandler-timeout=90 --instafail --pythonwarnings error --benchmark-columns=Min,Max,Median
testpaths = tests testpaths = tests
markers = markers =

View File

@ -22,7 +22,6 @@
import logging import logging
import pytest import pytest
import _pytest.logging
class LogFailHandler(logging.Handler): class LogFailHandler(logging.Handler):
@ -40,17 +39,8 @@ class LogFailHandler(logging.Handler):
if logger.name == 'messagemock': if logger.name == 'messagemock':
return 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 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, # caplog.at_level(...) was used with the level of this message,
# i.e. it was expected. # i.e. it was expected.
return return