Skip to content

The agent that grows with you

fix(tests): gate only the two AuthorizationCodeResult.code assertions on mcp 2.0

teknium1e4557d1febb7
diff --git a/tests/tools/test_mcp_oauth.py b/tests/tools/test_mcp_oauth.py
index 8d78fbaf202..17604fc57e0 100644
--- a/tests/tools/test_mcp_oauth.py
+++ b/tests/tools/test_mcp_oauth.py
@@ -543,7 +543,6 @@ class TestCallbackHandlerErrorEscaping:
# TOCTOU port reservation (#22161)
# ---------------------------------------------------------------------------
[email protected]("require_mcp_2_sdk")
class TestCallbackPortReservation:
"""The socket picked at selection time stays bound until callback bind.
@@ -578,6 +577,7 @@ class TestCallbackPortReservation:
assert cfg["_resolved_port"] == 49399
assert 49399 not in mod._reserved_sockets
+ @pytest.mark.usefixtures("require_mcp_2_sdk") # asserts the 2.0-only AuthorizationCodeResult.code
def test_wait_for_callback_adopts_reserved_socket(self, monkeypatch):
"""E2E: reserve → _wait_for_callback binds the SAME socket and the
callback round-trips through it."""
@@ -611,6 +611,7 @@ class TestCallbackPortReservation:
# Reservation was consumed by adoption.
assert port not in mod._reserved_sockets
+ @pytest.mark.usefixtures("require_mcp_2_sdk") # asserts the 2.0-only AuthorizationCodeResult.code
def test_concurrent_flows_keep_their_own_callback_ports(self, monkeypatch):
"""#34260: flow A's waiter listens on A's port even after flow B
overwrites the legacy module-level global.