Skip to content

Commit c76cb9c

Browse files
gh-155423: Make BaseFileTest.tearDown() in test_logging robust
Always call BaseTest.tearDown(), which removes the handlers added by setUp(), even if unlinking the log files fails. Tolerate an already removed file.
1 parent 998b890 commit c76cb9c

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Lib/test/test_logging.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6446,11 +6446,12 @@ def setUp(self):
64466446
self.rmfiles = []
64476447

64486448
def tearDown(self):
6449-
for fn in self.rmfiles:
6450-
os.unlink(fn)
6451-
if os.path.exists(self.fn):
6452-
os.unlink(self.fn)
6453-
BaseTest.tearDown(self)
6449+
try:
6450+
for fn in self.rmfiles:
6451+
os_helper.unlink(fn)
6452+
os_helper.unlink(self.fn)
6453+
finally:
6454+
BaseTest.tearDown(self)
64546455

64556456
def assertLogFile(self, filename):
64566457
"Assert a log file is there and register it for deletion"

0 commit comments

Comments
 (0)