diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 0828aae98dca167..10d2fffc421a1d6 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -6358,11 +6358,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"