Skip to content

Commit cfbb4c9

Browse files
Hmbownclaude
andcommitted
Fix MCP test for auto-reconnect behavior on Python 3.11
Mock connect() in test_call_tool_without_connection so the auto-reconnect path doesn't spawn a real subprocess that fails differently across Python versions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d4f9efe commit cfbb4c9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tests/test_mcp.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from __future__ import annotations
77

88
import json
9+
from unittest.mock import AsyncMock, patch
910

1011
import pytest
1112

@@ -33,6 +34,8 @@ def test_request_id_increments(self):
3334
async def test_call_tool_without_connection(self):
3435
config = MCPServerConfig(name="test", command="echo", args=[])
3536
client = MCPClient(config)
36-
result = await client.call_tool("test_tool", {"arg": "value"})
37+
# Mock connect to simulate reconnect failure (no real server)
38+
with patch.object(client, "connect", new_callable=AsyncMock, return_value=[]):
39+
result = await client.call_tool("test_tool", {"arg": "value"})
3740
data = json.loads(result)
3841
assert "error" in data

0 commit comments

Comments
 (0)