File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -75,18 +75,22 @@ async def test_405_get_stream_does_not_hang(caplog: pytest.LogCaptureFixture):
7575 async with streamable_http_client ("http://testserver/mcp" , http_client = http_client ) as (
7676 read_stream ,
7777 write_stream ,
78- _ ,
7978 ):
8079 async with ClientSession (read_stream , write_stream ) as session :
8180 # Initialize sends the initialized notification internally
82- init_result = await session .initialize ()
81+ with anyio .fail_after (5.0 ):
82+ init_result = await session .initialize ()
8383 assert isinstance (init_result , InitializeResult )
8484
85- # Give the GET stream task time to fail with 405
86- await anyio .sleep (0.2 )
85+ # Wait until the GET stream task fails with 405 and logs the expected message
86+ expected_log = "Server does not support GET for SSE events (405 Method Not Allowed)"
87+ with anyio .fail_after (5.0 ):
88+ while not any (expected_log in record .getMessage () for record in caplog .records ):
89+ await anyio .sleep (0.05 )
8790
8891 # This should not hang and will now complete successfully
89- tools_result = await session .list_tools ()
92+ with anyio .fail_after (5.0 ):
93+ tools_result = await session .list_tools ()
9094 assert len (tools_result .tools ) == 1
9195 assert tools_result .tools [0 ].name == "test_tool"
9296
You can’t perform that action at this time.
0 commit comments