diff --git a/tests/test_instance_lists.py b/tests/test_instance_lists.py index 1266f9cd0..f5191aad7 100644 --- a/tests/test_instance_lists.py +++ b/tests/test_instance_lists.py @@ -255,6 +255,22 @@ class ArchiveTests(unittest.TestCase): with open(path, "rb") as fh: self.assertEqual(fh.read(), data) + def test_case_only_spelling_of_a_missing_report_is_one_path(self): + # normcase keeps case on macOS, and samefile cannot see a file that has not been created. + with tempfile.TemporaryDirectory() as tmp: + folder = os.path.join(tmp, "Reports") + os.mkdir(folder) + probe = os.path.join(folder, "Probe.tmp") + with open(probe, "wb"): + pass + insensitive = os.path.exists(os.path.join(folder, "probe.tmp")) + os.remove(probe) + if not insensitive: + self.skipTest("volume keeps case") + first = os.path.join(tmp, "Reports", "out.json") + second = os.path.join(tmp, "reports", "out.json") + self.assertTrue(il.same_output_path(first, second)) + def test_json_that_is_a_directory_is_refused_before_the_scan(self): with tempfile.TemporaryDirectory() as tmp: path, _ = self._archive(tmp) diff --git a/tools/instance_lists.py b/tools/instance_lists.py index 7504665c5..86ec9b8d9 100644 --- a/tools/instance_lists.py +++ b/tools/instance_lists.py @@ -37,6 +37,9 @@ import zlib sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import world_index as wi # noqa: E402 (same 0x7a header, schema and stream helpers) +from report_paths import same_report_path # noqa: E402 + +same_output_path = same_report_path PROP_LIST, PROP_INST = 0xBA049770, 0xEA6B3A96 GRASS_LIST, GRASS_INST = 0x7C475B5D, 0xED86F522 @@ -327,15 +330,6 @@ def scan(path, T, start=None, limit=None): pos = s + max(used, 1) -def same_output_path(first, second): - if os.path.normcase(os.path.realpath(first)) == os.path.normcase(os.path.realpath(second)): - return True - try: - return os.path.samefile(first, second) - except OSError: - return False - - def _int_arg(text): try: return int(text, 0)