Skip to content

Commit 41ceb15

Browse files
authored
correctly call setUp/tearDown hooks
1 parent 70ba65a commit 41ceb15

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Lib/test/support/script_helper.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -352,22 +352,22 @@ class EnsureSafeUserHistory(unittest.TestCase):
352352

353353
@classmethod
354354
def setUpClass(cls):
355+
super().setUpClass()
355356
cls.__history_file = cls.__history_stat = None
356357
history_file = _site_gethistoryfile()
357358
if os.path.exists(history_file):
358359
cls.__history_file = history_file
359360
cls.__history_stat = _file_signature(history_file)
360361

361362
def tearDown(self):
363+
if self.__history_file is not None:
364+
self.assertTrue(
365+
os.path.exists(self.__history_file),
366+
f"PYTHON_HISTORY file ({self.__history_file!r}) was deleted"
367+
)
368+
self.assertEqual(
369+
self.__history_stat,
370+
_file_signature(self.__history_file),
371+
f"PYTHON_HISTORY file ({self.__history_file!r}) was altered"
372+
)
362373
super().tearDown()
363-
if self.__history_file is None:
364-
return
365-
self.assertTrue(
366-
os.path.exists(self.__history_file),
367-
f"PYTHON_HISTORY file ({self.__history_file!r}) was deleted"
368-
)
369-
self.assertEqual(
370-
self.__history_stat,
371-
_file_signature(self.__history_file),
372-
f"PYTHON_HISTORY file ({self.__history_file!r}) was altered"
373-
)

0 commit comments

Comments
 (0)