Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
b0f3b00
1
Parent(s): f091931
Remove old client test; ensure server starts on every test
Browse files
tests/client/test_streamable_http.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import asyncio
|
| 2 |
import json
|
| 3 |
import sys
|
| 4 |
-
from collections.abc import
|
| 5 |
|
| 6 |
import pytest
|
| 7 |
import uvicorn
|
|
@@ -87,9 +87,11 @@ def run_nested_server(host: str, port: int) -> None:
|
|
| 87 |
server.run()
|
| 88 |
|
| 89 |
|
| 90 |
-
@pytest.fixture(
|
| 91 |
-
def streamable_http_server() ->
|
| 92 |
with run_server_in_process(run_server, transport="streamable-http") as url:
|
|
|
|
|
|
|
| 93 |
yield f"{url}/mcp"
|
| 94 |
|
| 95 |
|
|
@@ -158,13 +160,3 @@ class TestTimeout:
|
|
| 158 |
) as client:
|
| 159 |
with pytest.raises(McpError):
|
| 160 |
await client.call_tool("sleep", {"seconds": 0.2}, timeout=0.1)
|
| 161 |
-
|
| 162 |
-
async def test_timeout_client_timeout_overrides_tool_call_timeout_if_lower(
|
| 163 |
-
self, streamable_http_server: str
|
| 164 |
-
):
|
| 165 |
-
with pytest.raises(McpError):
|
| 166 |
-
async with Client(
|
| 167 |
-
transport=StreamableHttpTransport(streamable_http_server),
|
| 168 |
-
timeout=0.1,
|
| 169 |
-
) as client:
|
| 170 |
-
await client.call_tool("sleep", {"seconds": 0.2}, timeout=2)
|
|
|
|
| 1 |
import asyncio
|
| 2 |
import json
|
| 3 |
import sys
|
| 4 |
+
from collections.abc import AsyncGenerator
|
| 5 |
|
| 6 |
import pytest
|
| 7 |
import uvicorn
|
|
|
|
| 87 |
server.run()
|
| 88 |
|
| 89 |
|
| 90 |
+
@pytest.fixture()
|
| 91 |
+
async def streamable_http_server() -> AsyncGenerator[str, None]:
|
| 92 |
with run_server_in_process(run_server, transport="streamable-http") as url:
|
| 93 |
+
async with Client(transport=StreamableHttpTransport(f"{url}/mcp")) as client:
|
| 94 |
+
assert await client.ping()
|
| 95 |
yield f"{url}/mcp"
|
| 96 |
|
| 97 |
|
|
|
|
| 160 |
) as client:
|
| 161 |
with pytest.raises(McpError):
|
| 162 |
await client.call_tool("sleep", {"seconds": 0.2}, timeout=0.1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|