logfail: Rename capturelog module.
When trying to use this as conftest for the updated tests, pytest_* would be interpreted as hook otherwise.
This commit is contained in:
parent
376edd739b
commit
f5d9e967ef
@ -24,7 +24,7 @@ import logging
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pytest_capturelog
|
import pytest_capturelog as caplog_mod
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# When using pytest for pyflakes/pep8/..., the plugin won't be available
|
# When using pytest for pyflakes/pep8/..., the plugin won't be available
|
||||||
# but conftest.py will still be loaded.
|
# but conftest.py will still be loaded.
|
||||||
@ -47,7 +47,7 @@ class LogFailHandler(logging.Handler):
|
|||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
|
|
||||||
for h in root_logger.handlers:
|
for h in root_logger.handlers:
|
||||||
if isinstance(h, pytest_capturelog.CaptureLogHandler):
|
if isinstance(h, caplog_mod.CaptureLogHandler):
|
||||||
caplog_handler = h
|
caplog_handler = h
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@ -86,12 +86,12 @@ def caplog_bug_workaround(request):
|
|||||||
multiple CaptureLogHandlers.
|
multiple CaptureLogHandlers.
|
||||||
"""
|
"""
|
||||||
yield
|
yield
|
||||||
if pytest_capturelog is None:
|
if caplog_mod is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
caplog_handlers = [h for h in root_logger.handlers
|
caplog_handlers = [h for h in root_logger.handlers
|
||||||
if isinstance(h, pytest_capturelog.CaptureLogHandler)]
|
if isinstance(h, caplog_mod.CaptureLogHandler)]
|
||||||
|
|
||||||
for h in caplog_handlers:
|
for h in caplog_handlers:
|
||||||
root_logger.removeHandler(h)
|
root_logger.removeHandler(h)
|
||||||
|
Loading…
Reference in New Issue
Block a user