Skip to content

Commit 7534898

Browse files
authored
Explicitly check case‐sensitivity of file system for tests (#19540)
Both macOS and Windows support using case‐sensitive file systems; this fixes the test suite in those situations.
1 parent 270142f commit 7534898

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

mypy/test/testcheck.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import os
66
import re
77
import sys
8+
import tempfile
9+
from pathlib import Path
810

911
from mypy import build
1012
from mypy.build import Graph
@@ -46,15 +48,16 @@
4648
if sys.version_info < (3, 13):
4749
typecheck_files.remove("check-python313.test")
4850

49-
# Special tests for platforms with case-insensitive filesystems.
50-
if sys.platform not in ("darwin", "win32"):
51-
typecheck_files.remove("check-modules-case.test")
52-
5351

5452
class TypeCheckSuite(DataSuite):
5553
files = typecheck_files
5654

5755
def run_case(self, testcase: DataDrivenTestCase) -> None:
56+
if os.path.basename(testcase.file) == "check-modules-case.test":
57+
with tempfile.NamedTemporaryFile(prefix="test", dir=".") as temp_file:
58+
temp_path = Path(temp_file.name)
59+
if not temp_path.with_name(temp_path.name.upper()).exists():
60+
pytest.skip("File system is not case‐insensitive")
5861
if lxml is None and os.path.basename(testcase.file) == "check-reports.test":
5962
pytest.skip("Cannot import lxml. Is it installed?")
6063
incremental = (

mypy/test/testfscache.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import os
66
import shutil
7-
import sys
87
import tempfile
98
import unittest
109

@@ -83,7 +82,7 @@ def test_isfile_case_other_directory(self) -> None:
8382
assert self.isfile_case(os.path.join(other, "other_dir.py"))
8483
assert not self.isfile_case(os.path.join(other, "Other_Dir.py"))
8584
assert not self.isfile_case(os.path.join(other, "bar.py"))
86-
if sys.platform in ("win32", "darwin"):
85+
if os.path.exists(os.path.join(other, "PKG/other_dir.py")):
8786
# We only check case for directories under our prefix, and since
8887
# this path is not under the prefix, case difference is fine.
8988
assert self.isfile_case(os.path.join(other, "PKG/other_dir.py"))

0 commit comments

Comments
 (0)