diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index b5885b985afd31..aaf4a1405a09c8 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -5321,6 +5321,7 @@ def test_should_not_rollover(self): # See bpo-45401. Should only ever rollover regular files fh = logging.handlers.TimedRotatingFileHandler( os.devnull, 'S', encoding="utf-8", backupCount=1) + self.addCleanup(fh.close) time.sleep(1.1) # a little over a second ... r = logging.makeLogRecord({'msg': 'testing - device file'}) self.assertFalse(fh.shouldRollover(r))