Skip to content

Commit 3d591c9

Browse files
[3.14] gh-155423: Make BaseFileTest.tearDown() in test_logging robust (GH-155424) (GH-155443)
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 1b1c61a commit 3d591c9

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

63066306
def tearDown(self):
6307-
for fn in self.rmfiles:
6308-
os.unlink(fn)
6309-
if os.path.exists(self.fn):
6310-
os.unlink(self.fn)
6311-
BaseTest.tearDown(self)
6307+
try:
6308+
for fn in self.rmfiles:
6309+
os_helper.unlink(fn)
6310+
os_helper.unlink(self.fn)
6311+
finally:
6312+
BaseTest.tearDown(self)
63126313

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

0 commit comments

Comments
 (0)