diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 42746d40d2c..14277369be4 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -689,6 +689,7 @@ def emit(self, record): self.assertEqual(len(logging._handlers), 0) refed_h = _OurHandler() + self.addCleanup(refed_h.sub_handler.stream.close) refed_h.name = 'because we need at least one for this test' self.assertGreater(len(logging._handlers), 0) self.assertGreater(len(logging._at_fork_reinit_lock_weakset), 1)