π The fast, Pythonic way to build MCP servers and clients.
test(mount): make unreachable proxy failures deterministic (#5584)
CharlesYXW0b1a6ba1b1cb
diff --git a/tests/server/mount/test_mount.py b/tests/server/mount/test_mount.pyindex 5f099a352..bff2cdca9 100644--- a/tests/server/mount/test_mount.py+++ b/tests/server/mount/test_mount.py@@ -1,8 +1,8 @@"""Basic mounting functionality tests."""import logging-import sys+import httpx2import pytestfrom mcp_types import TextContent@@ -12,6 +12,7 @@ from fastmcp.client.transports import SSETransportfrom fastmcp.server import create_proxyfrom fastmcp.tools.base import Toolfrom fastmcp.tools.tool_transform import TransformedTool+from tests.utilities.httpx2_mock import HTTPXMockclass TestBasicMount:@@ -241,10 +242,9 @@ class TestMultipleServerMount:assert any(t.name == "api_first_tool" for t in tools)assert any(t.name == "api_second_tool" for t in tools)- @pytest.mark.skipif(- sys.platform == "win32", reason="Windows asyncio networking timeouts."- )- async def test_mount_with_unreachable_proxy_servers(self, caplog):+ async def test_mount_with_unreachable_proxy_servers(+ self, caplog, httpx_mock: HTTPXMock+ ):"""Test graceful handling when multiple mounted servers fail to connect."""caplog.set_level(logging.DEBUG, logger="fastmcp")@@ -266,9 +266,12 @@ class TestMultipleServerMount:# Mount the working servermain_app.mount(working_app, "working")- # Use an unreachable port+ unreachable_url = "http://unreachable.test/sse/"+ httpx_mock.add_exception(+ httpx2.ConnectError("Connection refused"), url=unreachable_url+ )unreachable_client = Client(- transport=SSETransport("http://127.0.0.1:9999/sse/"),+ transport=SSETransport(unreachable_url),name="unreachable_client",)@@ -313,6 +316,7 @@ class TestMultipleServerMount:assert any("Error during list_prompts from provider" in msg for msg in warning_messages)+ assert httpx_mock.get_requests(url=unreachable_url)class TestPrefixConflictResolution: