Skip to content

Commit e26d4b7

Browse files
committed
fix ut:
1 parent 5ea7e08 commit e26d4b7

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

tests/test_url_handling.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest.mock import AsyncMock, patch
1+
from unittest.mock import AsyncMock, MagicMock, patch
22
import httpx
33
import pytest
44
from werkzeug.wrappers import Response
@@ -7,45 +7,27 @@
77

88

99
# Sync tests for the ep.make() function
10-
@pytest.mark.asyncio
11-
async def test_mcp_env_make_appends_trailing_slash():
10+
def test_mcp_env_make_appends_trailing_slash():
1211
"""
1312
Verify that ep.make() appends a trailing slash to the MCP server URL if it's missing.
1413
This prevents 307 redirects that can break HTTP clients.
1514
"""
1615
base_url = "http://localhost:8000/mcp"
1716
corrected_url = "http://localhost:8000/mcp/"
1817

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 = ep.make(base_url, n=1, seeds=[42])
26-
27-
mock_init.assert_awaited_once()
18+
envs = ep.make(base_url, n=1, seeds=[42])
2819

2920
assert len(envs.sessions) == 1
3021
assert envs.sessions[0].base_url == corrected_url
3122

3223

33-
@pytest.mark.asyncio
34-
async def test_mcp_env_make_keeps_existing_trailing_slash():
24+
def test_mcp_env_make_keeps_existing_trailing_slash():
3525
"""
3626
Verify that ep.make() does not add an extra slash if one is already present.
3727
"""
3828
base_url = "http://localhost:8000/mcp/"
3929

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 = ep.make(base_url, n=1, seeds=[42])
47-
48-
mock_init.assert_awaited_once()
30+
envs = ep.make(base_url, n=1, seeds=[42])
4931

5032
assert len(envs.sessions) == 1
5133
# The session's base_url should remain unchanged

0 commit comments

Comments
 (0)