1616
1717from __future__ import annotations
1818
19+ import ntpath
1920import os
2021import pathlib
2122import shutil
@@ -804,22 +805,37 @@ def fake_run_cmd(cmd: list[str], cwd: str | None = None) -> tuple[int, str]:
804805 assert check_new_py_files .get_vcs_added_files ('.' ) == set ()
805806
806807
807- def test_get_vcs_added_files_jj (monkeypatch : pytest .MonkeyPatch ) -> None :
808+ def _patch_windows_paths (monkeypatch : pytest .MonkeyPatch ) -> None :
809+ monkeypatch .setattr (check_new_py_files .os , 'path' , ntpath )
810+ monkeypatch .setattr (check_new_py_files .os , 'sep' , '\\ ' )
811+
812+
813+ @pytest .mark .parametrize ('windows' , [False , True ])
814+ def test_get_vcs_added_files_jj (
815+ monkeypatch : pytest .MonkeyPatch , windows : bool
816+ ) -> None :
808817 def fake_which (cmd : str ) -> str | None :
809818 return '/usr/bin/' + cmd if cmd == 'jj' else None
810819
811820 def fake_run_cmd (cmd : list [str ], cwd : str | None = None ) -> tuple [int , str ]:
812821 if cmd == ['jj' , 'root' ]:
813- return 0 , '/workspace'
822+ return 0 , r'C:\workspace' if windows else '/workspace'
814823 if cmd == ['jj' , 'diff' , '--summary' ]:
815824 return 0 , 'A src/google/adk/agents/_jj_agent.py\n M existing.py'
816825 return 1 , ''
817826
818827 monkeypatch .setattr (check_new_py_files .shutil , 'which' , fake_which )
819828 monkeypatch .setattr (check_new_py_files , '_run_cmd' , fake_run_cmd )
829+ if windows :
830+ _patch_windows_paths (monkeypatch )
820831
832+ expected = (
833+ 'C:/workspace/src/google/adk/agents/_jj_agent.py'
834+ if windows
835+ else '/workspace/src/google/adk/agents/_jj_agent.py'
836+ )
821837 added = check_new_py_files .get_vcs_added_files ('.' )
822- assert added == {'/workspace/src/google/adk/agents/_jj_agent.py' }
838+ assert added == {expected }
823839
824840
825841_HG_SYNCED_BASE_STATUS = [
@@ -833,22 +849,32 @@ def fake_run_cmd(cmd: list[str], cwd: str | None = None) -> tuple[int, str]:
833849_HG_WORKING_DIR_STATUS = ['hg' , 'status' , '--added' , '--no-status' ]
834850
835851
836- def test_get_vcs_added_files_hg (monkeypatch : pytest .MonkeyPatch ) -> None :
852+ @pytest .mark .parametrize ('windows' , [False , True ])
853+ def test_get_vcs_added_files_hg (
854+ monkeypatch : pytest .MonkeyPatch , windows : bool
855+ ) -> None :
837856 def fake_which (cmd : str ) -> str | None :
838857 return '/usr/bin/' + cmd if cmd == 'hg' else None
839858
840859 def fake_run_cmd (cmd : list [str ], cwd : str | None = None ) -> tuple [int , str ]:
841860 if cmd == ['hg' , 'root' ]:
842- return 0 , '/workspace'
861+ return 0 , r'C:\workspace' if windows else '/workspace'
843862 if cmd == _HG_SYNCED_BASE_STATUS :
844863 return 0 , 'src/google/adk/agents/_hg_agent.py'
845864 return 1 , ''
846865
847866 monkeypatch .setattr (check_new_py_files .shutil , 'which' , fake_which )
848867 monkeypatch .setattr (check_new_py_files , '_run_cmd' , fake_run_cmd )
868+ if windows :
869+ _patch_windows_paths (monkeypatch )
849870
871+ expected = (
872+ 'C:/workspace/src/google/adk/agents/_hg_agent.py'
873+ if windows
874+ else '/workspace/src/google/adk/agents/_hg_agent.py'
875+ )
850876 added = check_new_py_files .get_vcs_added_files ('.' )
851- assert added == {'/workspace/src/google/adk/agents/_hg_agent.py' }
877+ assert added == {expected }
852878
853879
854880def test_get_vcs_added_files_hg_sees_an_already_committed_add (
0 commit comments