diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-12-27 14:31:52 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-12-27 14:31:52 (GMT) |
commit | 7b60f4e9499c69e92a8eae7b3429290901466bf3 (patch) | |
tree | abb58dacd545feb57354a6a7f2dffb93dae9bf11 | |
parent | 60b4df15d633626d9a4584e1f25d2ad4d23d1522 (diff) | |
download | cpython-7b60f4e9499c69e92a8eae7b3429290901466bf3.zip cpython-7b60f4e9499c69e92a8eae7b3429290901466bf3.tar.gz cpython-7b60f4e9499c69e92a8eae7b3429290901466bf3.tar.bz2 |
Issue #10626: test_logging now preserves logger disabled states.
-rw-r--r-- | Lib/test/test_logging.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index cc30f67..8c8a5e7 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() |