From eb4a0a3da77f9085d3c036fe131a5256d72d653f Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Mon, 10 Aug 2026 02:15:15 -0700 Subject: [PATCH] test: read _MCP_LOGGING_CALLBACK_SUPPORTED via module after _ensure_mcp_sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SDK-support flag is now bound lazily (startup-latency change); a by-value module-level import freezes the pre-bind False. Read it off the module after _ensure_mcp_sdk() so the test observes the real support state — same contract, lazy-aware. --- tests/tools/test_mcp_server_log_notifications.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/tools/test_mcp_server_log_notifications.py b/tests/tools/test_mcp_server_log_notifications.py index 2e3a875349262..3a0c696380902 100644 --- a/tests/tools/test_mcp_server_log_notifications.py +++ b/tests/tools/test_mcp_server_log_notifications.py @@ -14,7 +14,6 @@ import pytest from tools.mcp_tool import ( _MCP_LOG_LEVEL_MAP, - _MCP_LOGGING_CALLBACK_SUPPORTED, MCPServerTask, ) @@ -77,7 +76,14 @@ class TestSDKSupportGate: # The pinned MCP SDK in this repo supports logging_callback; if this # starts failing after an SDK downgrade the feature silently degrades # (by design), but we want to know. + # + # Read the flag off the module AFTER _ensure_mcp_sdk() — the SDK + # import (and therefore this flag) is lazy since the startup-latency + # work, so a by-value module-level import would freeze the pre-bind + # False and never observe the real support state. import inspect from mcp import ClientSession + from tools import mcp_tool + mcp_tool._ensure_mcp_sdk() expected = "logging_callback" in inspect.signature(ClientSession).parameters - assert _MCP_LOGGING_CALLBACK_SUPPORTED == expected + assert mcp_tool._MCP_LOGGING_CALLBACK_SUPPORTED == expected