From e95f9fae7bf5a6768d5a233b155d7f60a343507b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xavier=20dupr=C3=A9?= Date: Sun, 13 Feb 2022 16:30:50 +0100 Subject: [PATCH] Removes logging propagation when catching it for unittest --- src/pyquickhelper/pycode/unittestclass.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pyquickhelper/pycode/unittestclass.py b/src/pyquickhelper/pycode/unittestclass.py index e3bacd3b..139a5193 100644 --- a/src/pyquickhelper/pycode/unittestclass.py +++ b/src/pyquickhelper/pycode/unittestclass.py @@ -23,7 +23,8 @@ class ExtTestCase(unittest.TestCase): *PendingDeprecationWarning* are filtered out. """ - def setUp(self): + @classmethod + def setUpClass(cls): """ Filters out *FutureWarning*, *PendingDeprecationWarning*. """ @@ -33,7 +34,8 @@ def setUp(self): ImportWarning, DeprecationWarning)) - def tearDown(self): + @classmethod + def tearDownClass(cls): """ Stops filtering out *FutureWarning*, *PendingDeprecationWarning*. """ @@ -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)