@@ -78,7 +78,11 @@ def test_get_npx_windows(monkeypatch: pytest.MonkeyPatch):
7878 import shutil
7979
8080 monkeypatch .setattr (sys , "platform" , "win32" )
81- monkeypatch .setattr (shutil , "which" , lambda name : "C:\\ bin\\ npx.exe" if name == "npx.exe" else None )
81+
82+ def fake_which (name : str ) -> str | None :
83+ return "C:\\ bin\\ npx.exe" if name == "npx.exe" else None
84+
85+ monkeypatch .setattr (shutil , "which" , fake_which )
8286 assert _get_npx_command () == ["C:\\ bin\\ npx.exe" ]
8387
8488
@@ -88,7 +92,11 @@ def test_get_npx_windows_cmd_wrapper(monkeypatch: pytest.MonkeyPatch):
8892
8993 monkeypatch .setattr (sys , "platform" , "win32" )
9094 monkeypatch .setenv ("COMSPEC" , "cmd.exe" )
91- monkeypatch .setattr (shutil , "which" , lambda name : "C:\\ bin\\ npx.cmd" if name == "npx.cmd" else None )
95+
96+ def fake_which (name : str ) -> str | None :
97+ return "C:\\ bin\\ npx.cmd" if name == "npx.cmd" else None
98+
99+ monkeypatch .setattr (shutil , "which" , fake_which )
92100
93101 assert _get_npx_command () == ["cmd.exe" , "/c" , "C:\\ bin\\ npx.cmd" ]
94102
@@ -98,5 +106,8 @@ def test_get_npx_returns_none_when_npx_missing(monkeypatch: pytest.MonkeyPatch):
98106 monkeypatch .setattr (sys , "platform" , "win32" , raising = False )
99107 import shutil
100108
101- monkeypatch .setattr (shutil , "which" , lambda name : None )
109+ def fake_which (name : str ) -> str | None :
110+ return None
111+
112+ monkeypatch .setattr (shutil , "which" , fake_which )
102113 assert _get_npx_command () is None
0 commit comments