From 7b60f4e9499c69e92a8eae7b3429290901466bf3 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Mon, 27 Dec 2010 14:31:52 +0000 Subject: [PATCH] Issue #10626: test_logging now preserves logger disabled states. --- Lib/test/test_logging.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index cc30f67e098..8c8a5e7181e 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -67,8 +67,12 @@ class BaseTest(unittest.TestCase): try: self.saved_handlers = logging._handlers.copy() self.saved_handler_list = logging._handlerList[:] - self.saved_loggers = logger_dict.copy() + self.saved_loggers = saved_loggers = logger_dict.copy() self.saved_level_names = logging._levelNames.copy() + self.logger_states = logger_states = {} + for name in saved_loggers: + logger_states[name] = getattr(saved_loggers[name], + 'disabled', None) finally: logging._releaseLock() @@ -112,6 +116,10 @@ class BaseTest(unittest.TestCase): loggerDict = logging.getLogger().manager.loggerDict loggerDict.clear() loggerDict.update(self.saved_loggers) + logger_states = self.logger_states + for name in self.logger_states: + if logger_states[name] is not None: + self.saved_loggers[name].disabled = logger_states[name] finally: logging._releaseLock()