test(mcp): drive MCP tool calls through asyncio.run - #1087
Closed
doublewhy wants to merge 1 commit into
Closed
Conversation
`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) <noreply@anthropic.com>
This was referenced Aug 12, 2026
Collaborator
|
Please note in the comments or body which issue this PR closes. If no issue exists, please create one and link it. Thank you! |
Author
|
Linked the focused Python 3.14 MCP test issue in the PR body: this PR closes #1117. Thank you. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plain-language summary
asyncio.run(), which creates and closes the loop explicitly.Related issues
Closes #1117
Required by the broader interpreter qualification in #1097.
What breaks
tests/test_mcp_server.pyfails entirely — all 85 tests — on Python 3.14. It passes today only because CI pins 3.12, where the same call is merely deprecated.Concretely
The module drives its async MCP calls from synchronous test code like this:
Calling
asyncio.get_event_loop()with no running loop has emitted a DeprecationWarning since 3.12. In 3.14 it raises:So the file is one interpreter bump away from taking out the whole MCP test module, and it currently adds a DeprecationWarning to every run of the suite.
I hit this for real: running the full gate on a Linux host where
uvselected 3.14 rather than the pinned 3.12, ~20 of these failed before I noticed the interpreter mismatch.The fix
asyncio.run(...), which is the supported way to drive a coroutine from sync code. Two call sites. Tests only — no package code changes.How I know
I reproduced 3.14's behaviour on 3.12 by promoting the warning to an error, since it is the same call that hard-fails there:
DeprecationWarning: There is no current event looperrors the moduleFull hermetic suite green. The suite's warning count drops by one, because this was the source.
🤖 Generated with Claude Code