diff options
Diffstat (limited to 'Lib/test/test_logging.py')
| -rw-r--r-- | Lib/test/test_logging.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index b2e3327..48add6d 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -2255,7 +2255,7 @@ class RecordingHandler(logging.NullHandler): class ShutdownTest(BaseTest): - """Tets suite for the shutdown method.""" + """Test suite for the shutdown method.""" def setUp(self): super(ShutdownTest, self).setUp() @@ -2342,7 +2342,7 @@ class ShutdownTest(BaseTest): class ModuleLevelMiscTest(BaseTest): - """Tets suite for some module level methods.""" + """Test suite for some module level methods.""" def test_disable(self): old_disable = logging.root.manager.disable @@ -2356,7 +2356,7 @@ class ModuleLevelMiscTest(BaseTest): def _test_log(self, method, level=None): called = [] patch(self, logging, 'basicConfig', - lambda *a, **kw: called.append(a, kw)) + lambda *a, **kw: called.append((a, kw))) recording = RecordingHandler() logging.root.addHandler(recording) @@ -2410,19 +2410,30 @@ class ModuleLevelMiscTest(BaseTest): class BasicConfigTest(unittest.TestCase): - """Tets suite for logging.basicConfig.""" + """Test suite for logging.basicConfig.""" def setUp(self): super(BasicConfigTest, self).setUp() - handlers = logging.root.handlers - self.addCleanup(lambda: setattr(logging.root, 'handlers', handlers)) + self.handlers = logging.root.handlers + self.saved_handlers = logging._handlers.copy() + self.saved_handler_list = logging._handlerList[:] + self.original_logging_level = logging.root.level + self.addCleanup(self.cleanup) logging.root.handlers = [] def tearDown(self): - logging.shutdown() + for h in logging.root.handlers[:]: + logging.root.removeHandler(h) + h.close() super(BasicConfigTest, self).tearDown() - @unittest.skipIf(True, "test disabled, issue #11557") + def cleanup(self): + setattr(logging.root, 'handlers', self.handlers) + logging._handlers.clear() + logging._handlers.update(self.saved_handlers) + logging._handlerList[:] = self.saved_handler_list + logging.root.level = self.original_logging_level + def test_no_kwargs(self): logging.basicConfig() @@ -2441,7 +2452,7 @@ class BasicConfigTest(unittest.TestCase): self.assertIsInstance(formatter._style, logging.PercentStyle) # level is not explicitely set - self.assertEqual(logging.root.level, logging.WARNING) + self.assertEqual(logging.root.level, self.original_logging_level) def test_filename(self): logging.basicConfig(filename='test.log') |
