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

Method test_handles_cancellation

tests/agents/test_loop.py:143–163  ·  view source on GitHub ↗

Loop handles CancelledError gracefully.

(self)

Source from the content-addressed store, hash-verified

141
142 @pytest.mark.asyncio
143 async def test_handles_cancellation(self):
144 """Loop handles CancelledError gracefully."""
145 ctx = _make_context()
146 ui = _make_ui()
147 q: asyncio.Queue = asyncio.Queue()
148 done = asyncio.Event()
149
150 mock_convo = MagicMock()
151 mock_convo.process_conversation = AsyncMock(
152 side_effect=asyncio.CancelledError()
153 )
154
155 await q.put("do something")
156
157 with patch(
158 "mcp_cli.chat.conversation.ConversationProcessor",
159 return_value=mock_convo,
160 ):
161 await run_agent_loop(ctx, ui, q, done)
162
163 assert done.is_set()
164
165 @pytest.mark.asyncio
166 async def test_handles_exception(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