Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Removes logging propagation when catching it for unittest (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Feb 13, 2022
1 parent 53af941 commit 2950804
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pyquickhelper/pycode/unittestclass.py
Expand Up @@ -23,7 +23,8 @@ class ExtTestCase(unittest.TestCase):
*PendingDeprecationWarning* are filtered out.
"""

def setUp(self):
@classmethod
def setUpClass(cls):
"""
Filters out *FutureWarning*, *PendingDeprecationWarning*.
"""
Expand All @@ -33,7 +34,8 @@ def setUp(self):
ImportWarning,
DeprecationWarning))

def tearDown(self):
@classmethod
def tearDownClass(cls):
"""
Stops filtering out *FutureWarning*, *PendingDeprecationWarning*.
"""
Expand Down Expand Up @@ -545,7 +547,10 @@ def __len__(self):
raise AssertionError( # pragma: no cover
"Logger %r has no handlers." % logger_name)

prop = logger.propagate
logger.propagate = False
res = fct()
logger.propagate = prop

logs = log_capture_string.getvalue()
logger.removeHandler(ch)
Expand Down

0 comments on commit 2950804

Please sign in to comment.