test: isolate MCP reconnect DNS transport
Maintainer edit: the real MCP reconnect regression test can bind the class-level PinnedDNSAsyncTransport lock to its pytest event loop. Patch the MCP module to use a test-local transport subclass so later async tests do not inherit that loop-bound lock.
This commit is contained in:
@@ -128,6 +128,10 @@ def _make_loop(tmp_path, *, mcp_servers: dict) -> AgentLoop:
|
|||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def allow_loopback_mcp_urls(monkeypatch: pytest.MonkeyPatch):
|
def allow_loopback_mcp_urls(monkeypatch: pytest.MonkeyPatch):
|
||||||
"""The repro server runs on 127.0.0.1; allow nanobot to talk to it."""
|
"""The repro server runs on 127.0.0.1; allow nanobot to talk to it."""
|
||||||
|
class TestPinnedDNSAsyncTransport(security_network.PinnedDNSAsyncTransport):
|
||||||
|
_resolver_lock = asyncio.Lock()
|
||||||
|
|
||||||
|
monkeypatch.setattr(mcp_module, "PinnedDNSAsyncTransport", TestPinnedDNSAsyncTransport)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
mcp_module,
|
mcp_module,
|
||||||
"validate_url_target",
|
"validate_url_target",
|
||||||
|
|||||||
Reference in New Issue
Block a user