1- import asyncio
2-
1+ from unittest .mock import AsyncMock , patch
32import httpx
43import pytest
54from werkzeug .wrappers import Response
@@ -17,11 +16,17 @@ async def test_mcp_env_make_appends_trailing_slash():
1716 base_url = "http://localhost:8000/mcp"
1817 corrected_url = "http://localhost:8000/mcp/"
1918
20- # Use n and seeds to avoid needing a full dataset
21- envs = await ep .make (base_url , n = 1 , seeds = [42 ])
19+ with patch (
20+ "eval_protocol.mcp.client.connection.MCPConnectionManager.initialize_session" ,
21+ new_callable = AsyncMock ,
22+ ) as mock_init :
23+ mock_init .return_value = None
24+
25+ envs = await ep .make (base_url , n = 1 , seeds = [42 ])
26+
27+ mock_init .assert_awaited_once ()
2228
2329 assert len (envs .sessions ) == 1
24- # The session's base_url should have the trailing slash
2530 assert envs .sessions [0 ].base_url == corrected_url
2631
2732
@@ -32,8 +37,15 @@ async def test_mcp_env_make_keeps_existing_trailing_slash():
3237 """
3338 base_url = "http://localhost:8000/mcp/"
3439
35- # Use n and seeds to avoid needing a full dataset
36- envs = await ep .make (base_url , n = 1 , seeds = [42 ])
40+ with patch (
41+ "eval_protocol.mcp.client.connection.MCPConnectionManager.initialize_session" ,
42+ new_callable = AsyncMock ,
43+ ) as mock_init :
44+ mock_init .return_value = None
45+
46+ envs = await ep .make (base_url , n = 1 , seeds = [42 ])
47+
48+ mock_init .assert_awaited_once ()
3749
3850 assert len (envs .sessions ) == 1
3951 # The session's base_url should remain unchanged
0 commit comments