Skip to content

Commit def1575

Browse files
[3.13] gh-155423: Make BaseFileTest.tearDown() in test_logging robust (GH-155424) (GH-155442)
Always call BaseTest.tearDown(), which removes the handlers added by setUp(), even if unlinking the log files fails. Tolerate an already removed file. (cherry picked from commit 6f7fb6c) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 00afccf commit def1575

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
@@ -6244,11 +6244,12 @@ def setUp(self):
62446244
self.rmfiles = []
62456245

62466246
def tearDown(self):
6247-
for fn in self.rmfiles:
6248-
os.unlink(fn)
6249-
if os.path.exists(self.fn):
6250-
os.unlink(self.fn)
6251-
BaseTest.tearDown(self)
6247+
try:
6248+
for fn in self.rmfiles:
6249+
os_helper.unlink(fn)
6250+
os_helper.unlink(self.fn)
6251+
finally:
6252+
BaseTest.tearDown(self)
62526253

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

0 commit comments

Comments
 (0)