From 19befe76a6a7636a47c18e34be65ca01c572793d Mon Sep 17 00:00:00 2001 From: Jason Cat Date: Fri, 9 Oct 2026 17:08:56 +0800 Subject: [PATCH] fix(tests): stop hardcoding C: in the Windows file-URI migration tests (#6541) The two Windows-only cases in tests/test_mcp_file_migration.py asserted a literal "file:///C:/" / "file://C:" prefix on a path built from the pytest temp dir. On a host whose checkout or temp dir lives on another drive both assertions fail, so the only coverage of the drive-qualified file-URI forms handled by _local_uri_to_virtual_path and _rewrite_local_paths_in_text never ran there. Derive the expected drive from the fixture path instead. The URI forms under test are unchanged, so coverage holds on any drive. Co-authored-by: Willem Jiang --- backend/tests/test_mcp_file_migration.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/tests/test_mcp_file_migration.py b/backend/tests/test_mcp_file_migration.py index dbb014b26d..804e4dca8f 100644 --- a/backend/tests/test_mcp_file_migration.py +++ b/backend/tests/test_mcp_file_migration.py @@ -143,7 +143,9 @@ class TestLocalUriToVirtualPath: @pytest.mark.skipif(os.name != "nt", reason="exercises the file:///C:/... drive-qualified URI form") def test_windows_file_uri_translates_to_virtual_path(self, paths: Paths): src = _workspace_file(paths, "shot.png") - assert src.as_uri().startswith("file:///C:/") + # The checkout and temp dirs may live on any drive, so derive the + # expected drive instead of hardcoding "C:". + assert src.as_uri().startswith(f"file:///{src.drive}/") with _patch_paths(paths): result = mcp_tools._local_uri_to_virtual_path(src.as_uri(), thread_id="t1", user_id="u1") @@ -372,7 +374,7 @@ class TestRewriteLocalPathsInText: def test_windows_two_slash_file_uri_in_text_is_rewritten(self, paths: Paths): src = _workspace_file(paths, "shot.png") two_slash_uri = src.as_uri().replace("file:///", "file://", 1) - assert two_slash_uri.startswith("file://C:") + assert two_slash_uri.startswith(f"file://{src.drive}") with _patch_paths(paths): result = mcp_tools._rewrite_local_paths_in_text(f"Saved as {two_slash_uri}", thread_id="t1", user_id="u1")