MCPcopy
hub / github.com/MinishLab/semble / test_cli_entrypoint_works_without_mcp_installed

Function test_cli_entrypoint_works_without_mcp_installed

tests/test_cli.py:113–136  ·  view source on GitHub ↗

CLI entrypoint paths succeed even when the mcp package is not installed.

(
    argv: list[str],
    expected_stdout: str,
    expect_system_exit: bool,
    monkeypatch: pytest.MonkeyPatch,
    capsys: pytest.CaptureFixture[str],
)

Source from the content-addressed store, hash-verified

111 ],
112)
113def test_cli_entrypoint_works_without_mcp_installed(
114 argv: list[str],
115 expected_stdout: str,
116 expect_system_exit: bool,
117 monkeypatch: pytest.MonkeyPatch,
118 capsys: pytest.CaptureFixture[str],
119) -> None:
120 """CLI entrypoint paths succeed even when the mcp package is not installed."""
121 chunk = make_chunk("def foo(): pass", "src/foo.py")
122 fake_index = MagicMock()
123 fake_index.search.return_value = [SearchResult(chunk=chunk, score=0.9)]
124 monkeypatch.setattr(sys, "argv", argv)
125 monkeypatch.setitem(sys.modules, "mcp", None)
126 monkeypatch.setitem(sys.modules, "mcp.server", None)
127 monkeypatch.setitem(sys.modules, "mcp.server.fastmcp", None)
128 monkeypatch.setitem(sys.modules, "semble.mcp", None)
129 with patch("semble.cli.SembleIndex.from_path", return_value=fake_index):
130 if expect_system_exit:
131 with pytest.raises(SystemExit) as exc_info:
132 main()
133 assert exc_info.value.code == 0
134 else:
135 main()
136 assert expected_stdout in capsys.readouterr().out
137
138
139def test_mcp_main_exits_with_message_when_extras_missing(

Callers

nothing calls this directly

Calls 3

make_chunkFunction · 0.90
SearchResultClass · 0.90
mainFunction · 0.90

Tested by

no test coverage detected