diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index d74670609ec019..90c38557d2e21b 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -6446,11 +6446,12 @@ def setUp(self): self.rmfiles = [] def tearDown(self): - for fn in self.rmfiles: - os.unlink(fn) - if os.path.exists(self.fn): - os.unlink(self.fn) - BaseTest.tearDown(self) + try: + for fn in self.rmfiles: + os_helper.unlink(fn) + os_helper.unlink(self.fn) + finally: + BaseTest.tearDown(self) def assertLogFile(self, filename): "Assert a log file is there and register it for deletion"