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],
)
| 111 | ], |
| 112 | ) |
| 113 | def 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 | |
| 139 | def test_mcp_main_exits_with_message_when_extras_missing( |
nothing calls this directly
no test coverage detected