From 40ddab317dcaed0b825a7b5607f0e5d6f0edd534 Mon Sep 17 00:00:00 2001 From: Yernat Yestekov Date: Tue, 11 Aug 2026 19:35:15 -0700 Subject: [PATCH] test(mcp): drive MCP tool calls through asyncio.run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `asyncio.get_event_loop()` outside a running loop has warned since 3.12 and raises `RuntimeError: There is no current event loop` on 3.14, so the whole module fails there — 20+ tests — while only emitting a DeprecationWarning on the interpreters CI currently pins. `asyncio.run` is the supported spelling for driving a coroutine from sync test code. Verified by running the module under `-W error::DeprecationWarning`, which reproduces the 3.14 failure: the previous spelling errors out, this one passes all 85 tests. Co-Authored-By: Claude Opus 5 (1M context) --- implementations/python/tests/test_mcp_server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/implementations/python/tests/test_mcp_server.py b/implementations/python/tests/test_mcp_server.py index 57c736697..89f409bad 100644 --- a/implementations/python/tests/test_mcp_server.py +++ b/implementations/python/tests/test_mcp_server.py @@ -31,7 +31,7 @@ def _text(result) -> str: def _call(server, tool: str, args: dict | None = None) -> str: """Synchronously call a tool and return its text.""" - return asyncio.get_event_loop().run_until_complete(_async_call(server, tool, args or {})) + return asyncio.run(_async_call(server, tool, args or {})) async def _async_call(server, tool: str, args: dict) -> str: @@ -897,7 +897,7 @@ def test_server_has_all_tools(self): # Using the real registration surface (rather than a hand-copied # literal) means a drift between what the server exposes and what # raes_tool_surface advertises cannot pass silently. - registered = asyncio.get_event_loop().run_until_complete(server.list_tools()) + registered = asyncio.run(server.list_tools()) registered_names = {tool.name for tool in registered} assert registered_names, "server registered no tools"