MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / test_get_npx_windows

Function test_get_npx_windows

tests/cli/test_utils.py:97–109  ·  view source on GitHub ↗

Should return one of the npx candidates on Windows.

(monkeypatch: pytest.MonkeyPatch)

Source from the content-addressed store, hash-verified

95
96
97def test_get_npx_windows(monkeypatch: pytest.MonkeyPatch):
98 """Should return one of the npx candidates on Windows."""
99 candidates = ["npx.cmd", "npx.exe", "npx"]
100
101 def fake_run(cmd: list[str], **kw: Any) -> subprocess.CompletedProcess[bytes]:
102 if cmd[0] in candidates:
103 return subprocess.CompletedProcess(cmd, 0)
104 else: # pragma: no cover
105 raise subprocess.CalledProcessError(1, cmd[0])
106
107 monkeypatch.setattr(sys, "platform", "win32")
108 monkeypatch.setattr(subprocess, "run", fake_run)
109 assert _get_npx_command() in candidates
110
111
112def test_get_npx_returns_none_when_npx_missing(monkeypatch: pytest.MonkeyPatch):

Callers

nothing calls this directly

Calls 1

_get_npx_commandFunction · 0.90

Tested by

no test coverage detected