Skip to content

Commit

Permalink
fix pystack test
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaigh0 committed Jan 14, 2025
1 parent 09aa698 commit 8569ea0
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +

from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryDirectory
from time import sleep
from unittest import TestCase
Expand Down Expand Up @@ -49,16 +50,16 @@ def test_get_most_recent_core_dump_file_gets_the_latest_file(self, mock_check_wo
for name in file_names:
open(f"{tmp_dir}/{name}", "a").close()
sleep(0.1)
latest_file = _get_most_recent_core_dump_file(tmp_dir)
latest_file = _get_most_recent_core_dump_file(Path(tmp_dir))
self.assertEqual(latest_file.name, file_names[-1])

@patch(f"{MODULE_PATH}.CORE_DUMP_RECENCY_LIMIT", 0.5)
def test_get_most_recent_core_dump_file_returns_none_if_there_are_no_new_files(self):
with TemporaryDirectory() as tmp_dir:
open(f"{tmp_dir}/test", "a").close()
sleep(0.6)
self.assertIsNone(_get_most_recent_core_dump_file(tmp_dir))
self.assertIsNone(_get_most_recent_core_dump_file(Path(tmp_dir)))

def test_get_most_recent_core_dump_file_returns_none_if_the_dir_is_empty(self):
with TemporaryDirectory() as tmp_dir:
self.assertIsNone(_get_most_recent_core_dump_file(tmp_dir))
self.assertIsNone(_get_most_recent_core_dump_file(Path(tmp_dir)))

0 comments on commit 8569ea0

Please sign in to comment.