Skip to content

Commit 81dcdfa

Browse files
serhiy-storchakamiss-islington
authored andcommitted
gh-155423: Make BaseFileTest.tearDown() in test_logging robust (GH-155424)
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 a1ab3b0 commit 81dcdfa

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

63606360
def tearDown(self):
6361-
for fn in self.rmfiles:
6362-
os.unlink(fn)
6363-
if os.path.exists(self.fn):
6364-
os.unlink(self.fn)
6365-
BaseTest.tearDown(self)
6361+
try:
6362+
for fn in self.rmfiles:
6363+
os_helper.unlink(fn)
6364+
os_helper.unlink(self.fn)
6365+
finally:
6366+
BaseTest.tearDown(self)
63666367

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

0 commit comments

Comments
 (0)