|
10 | 10 | ROOT = Path(__file__).resolve().parents[1] |
11 | 11 |
|
12 | 12 |
|
| 13 | +def _long_windows_path(path): |
| 14 | + text = str(path) |
| 15 | + if os.name != "nt": |
| 16 | + return text |
| 17 | + try: |
| 18 | + import ctypes |
| 19 | + |
| 20 | + buffer = ctypes.create_unicode_buffer(32768) |
| 21 | + result = ctypes.windll.kernel32.GetLongPathNameW(text, buffer, len(buffer)) |
| 22 | + if result: |
| 23 | + return buffer.value |
| 24 | + except Exception: |
| 25 | + pass |
| 26 | + return text |
| 27 | + |
| 28 | + |
| 29 | +def _path_variants(path): |
| 30 | + values = {str(path), _long_windows_path(path)} |
| 31 | + return {value for value in values if value} |
| 32 | + |
| 33 | + |
| 34 | +def _paths_equal(left, right): |
| 35 | + left_values = {os.path.normcase(os.path.normpath(value)) for value in _path_variants(left)} |
| 36 | + right_values = {os.path.normcase(os.path.normpath(value)) for value in _path_variants(right)} |
| 37 | + return not left_values.isdisjoint(right_values) |
| 38 | + |
| 39 | + |
| 40 | +def _assert_path_equal(testcase, left, right): |
| 41 | + testcase.assertTrue(_paths_equal(left, right), f"{left!r} is not the same path as {right!r}") |
| 42 | + |
| 43 | + |
| 44 | +def _assert_path_in_text(testcase, path, text): |
| 45 | + escaped_variants = {value.replace("\\", "\\\\") for value in _path_variants(path)} |
| 46 | + testcase.assertTrue(any(value in text for value in escaped_variants), f"none of {escaped_variants!r} found in text") |
| 47 | + |
| 48 | + |
| 49 | +def _assert_path_in_values(testcase, path, values): |
| 50 | + testcase.assertTrue(any(_paths_equal(value, path) for value in values), f"{path!r} not found in {values!r}") |
| 51 | + |
| 52 | + |
13 | 53 | class AgentReadinessTests(unittest.TestCase): |
14 | 54 | def test_project_mcp_config_uses_bootstrap_runner(self): |
15 | 55 | config = json.loads((ROOT / ".mcp.json").read_text(encoding="utf-8")) |
|
0 commit comments