From 5ec69ad5418542b77770c8a5d0014cb524013b0a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 11 Oct 2021 09:57:59 +0200 Subject: [PATCH] bpo-45401: Fix ResourceWarning in test_logging Fix ResourceWarning in test_logging.test_should_not_rollover(). --- Lib/test/test_logging.py | 1 + 1 file changed, 1 insertion(+) 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))