MCPcopy Create free account
hub / github.com/IBM/mcp-cli / test_handles_exception

Method test_handles_exception

tests/agents/test_loop.py:166–185  ·  view source on GitHub ↗

Loop handles unexpected exceptions.

(self)

Source from the content-addressed store, hash-verified

164
165 @pytest.mark.asyncio
166 async def test_handles_exception(self):
167 """Loop handles unexpected exceptions."""
168 ctx = _make_context()
169 ui = _make_ui()
170 q: asyncio.Queue = asyncio.Queue()
171 done = asyncio.Event()
172
173 mock_convo = MagicMock()
174 mock_convo.process_conversation = AsyncMock(side_effect=RuntimeError("boom"))
175
176 await q.put("do something")
177
178 with patch(
179 "mcp_cli.chat.conversation.ConversationProcessor",
180 return_value=mock_convo,
181 ):
182 result = await run_agent_loop(ctx, ui, q, done)
183
184 assert done.is_set()
185 assert "Error" in result
186
187 @pytest.mark.asyncio
188 async def test_exit_requested_stops_loop(self):

Callers

nothing calls this directly

Calls 3

run_agent_loopFunction · 0.90
_make_contextFunction · 0.70
_make_uiFunction · 0.70

Tested by

no test coverage detected