|
76 | 76 | "captured_stdin", "captured_stderr", |
77 | 77 | # filesystem |
78 | 78 | "TESTFN", "SAVEDCWD", "unlink", "rmtree", "temp_cwd", "findfile", |
79 | | - "create_empty_file", "can_symlink", |
| 79 | + "create_empty_file", "can_symlink", "fs_is_case_insensitive", |
80 | 80 | # unittest |
81 | 81 | "is_resource_enabled", "requires", "requires_freebsd_version", |
82 | 82 | "requires_linux_version", "requires_mac_ver", "check_syntax_error", |
@@ -2045,6 +2045,20 @@ def skip_unless_xattr(test): |
2045 | 2045 | return test if ok else unittest.skip(msg)(test) |
2046 | 2046 |
|
2047 | 2047 |
|
| 2048 | +def fs_is_case_insensitive(directory): |
| 2049 | + """Detects if the file system for the specified directory is case-insensitive.""" |
| 2050 | + base_fp, base_path = tempfile.mkstemp(dir=directory) |
| 2051 | + case_path = base_path.upper() |
| 2052 | + if case_path == base_path: |
| 2053 | + case_path = base_path.lower() |
| 2054 | + try: |
| 2055 | + return os.path.samefile(base_path, case_path) |
| 2056 | + except FileNotFoundError: |
| 2057 | + return False |
| 2058 | + finally: |
| 2059 | + os.unlink(base_path) |
| 2060 | + |
| 2061 | + |
2048 | 2062 | class SuppressCrashReport: |
2049 | 2063 | """Try to prevent a crash report from popping up. |
2050 | 2064 |
|
|
0 commit comments