Browse Source

Fixed Pytest 3.4 logging error. (#4912)

* pytest 3.6.3

* pytest 3.8

* attempt to fix pytest logging error
Asif Saif Uddin 6 years ago
parent
commit
16f56fe6f8
2 changed files with 7 additions and 3 deletions
  1. 1 1
      requirements/test.txt
  2. 6 2
      t/unit/conftest.py

+ 1 - 1
requirements/test.txt

@@ -1,2 +1,2 @@
 case>=1.3.1
-pytest>=3.0,<3.3
+pytest>=3.8.0,<3.9

+ 6 - 2
t/unit/conftest.py

@@ -230,9 +230,11 @@ def sanity_stdouts(request):
 
 @pytest.fixture(autouse=True)
 def sanity_logging_side_effects(request):
+    from _pytest.logging import LogCaptureHandler
     root = logging.getLogger()
     rootlevel = root.level
-    roothandlers = root.handlers
+    roothandlers = [
+        x for x in root.handlers if not isinstance(x, LogCaptureHandler)]
 
     yield
 
@@ -240,7 +242,9 @@ def sanity_logging_side_effects(request):
     root_now = logging.getLogger()
     if root_now.level != rootlevel:
         raise RuntimeError(CASE_LOG_LEVEL_EFFECT.format(this))
-    if root_now.handlers != roothandlers:
+    newhandlers = [x for x in root_now.handlers if not isinstance(
+        x, LogCaptureHandler)]
+    if newhandlers != roothandlers:
         raise RuntimeError(CASE_LOG_HANDLER_EFFECT.format(this))