Remove pytest-catchlog

This commit is contained in:
Florian Bruhin 2017-12-04 16:55:57 +01:00
parent 956c257d19
commit 2cdc32ca58
6 changed files with 7 additions and 46 deletions

View File

@ -12,12 +12,6 @@ git+https://github.com/jenisys/parse_type.git
hg+https://bitbucket.org/pytest-dev/py
git+https://github.com/pytest-dev/pytest.git@features
git+https://github.com/pytest-dev/pytest-bdd.git
# This is broken at the moment because logfail tries to access
# LogCaptureHandler
# git+https://github.com/eisensheng/pytest-catchlog.git
pytest-catchlog==1.2.2
git+https://github.com/pytest-dev/pytest-cov.git
git+https://github.com/pytest-dev/pytest-faulthandler.git
git+https://github.com/pytest-dev/pytest-instafail.git

View File

@ -23,7 +23,6 @@ py-cpuinfo==3.3.0
pytest==3.3.0
pytest-bdd==2.19.0
pytest-benchmark==3.1.1
pytest-catchlog==1.2.2
pytest-cov==2.5.1
pytest-faulthandler==1.3.1
pytest-instafail==0.3.0

View File

@ -7,7 +7,6 @@ hypothesis
pytest
pytest-bdd
pytest-benchmark
pytest-catchlog
pytest-cov
pytest-faulthandler
pytest-instafail

View File

@ -22,16 +22,7 @@
import logging
import pytest
try:
import pytest_catchlog as catchlog_mod
except ImportError:
# When using pytest for pyflakes/pep8/..., the plugin won't be available
# but conftest.py will still be loaded.
#
# However, LogFailHandler.emit will never be used in that case, so we just
# ignore the ImportError.
pass
import _pytest.logging
class LogFailHandler(logging.Handler):
@ -50,8 +41,8 @@ class LogFailHandler(logging.Handler):
return
for h in root_logger.handlers:
if isinstance(h, catchlog_mod.LogCaptureHandler):
catchlog_handler = h
if isinstance(h, _pytest.logging.LogCaptureHandler):
capture_handler = h
break
else:
# The LogCaptureHandler is not available anymore during fixture
@ -59,7 +50,7 @@ class LogFailHandler(logging.Handler):
return
if (logger.level == record.levelno or
catchlog_handler.level == record.levelno):
capture_handler.level == record.levelno):
# caplog.at_level(...) was used with the level of this message,
# i.e. it was expected.
return

View File

@ -23,7 +23,6 @@
import logging
import pytest
import pytest_catchlog
def test_log_debug():
@ -64,24 +63,3 @@ def test_log_expected_wrong_logger(caplog):
with pytest.raises(pytest.fail.Exception):
with caplog.at_level(logging.ERROR, logger):
logging.error('foo')
@pytest.fixture
def skipping_fixture():
pytest.skip("Skipping to test caplog workaround.")
def test_caplog_bug_workaround_1(caplog, skipping_fixture):
pass
def test_caplog_bug_workaround_2():
"""Make sure caplog_bug_workaround works correctly after a skipped test.
There should be only one capturelog handler.
"""
caplog_handler = None
for h in logging.getLogger().handlers:
if isinstance(h, pytest_catchlog.LogCaptureHandler):
assert caplog_handler is None
caplog_handler = h

View File

@ -27,7 +27,7 @@ import warnings
import attr
import pytest
import pytest_catchlog
import _pytest.logging
from qutebrowser.utils import log
from qutebrowser.misc import utilcmds
@ -66,11 +66,11 @@ def restore_loggers():
while root_logger.handlers:
h = root_logger.handlers[0]
root_logger.removeHandler(h)
if not isinstance(h, pytest_catchlog.LogCaptureHandler):
if not isinstance(h, _pytest.logging.LogCaptureHandler):
h.close()
root_logger.setLevel(original_logging_level)
for h in root_handlers:
if not isinstance(h, pytest_catchlog.LogCaptureHandler):
if not isinstance(h, _pytest.logging.LogCaptureHandler):
# https://github.com/qutebrowser/qutebrowser/issues/856
root_logger.addHandler(h)
logging._acquireLock()