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:
parent
9eefbf24a2
commit
20d5b4e384
@ -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 =
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user