1- import asyncio
21import sys
32
3+ import anyio
44import pytest
55
66from mcp import ClientSession , StdioServerParameters
77from mcp .client .stdio import stdio_client
88
9- # @pytest.mark.skipif(sys.platform != "win32", reason="Windows-specific test")
10- @pytest .mark .skipif (sys .version_info < ( 3 , 11 ), reason = "asyncio.timeout in 3.11+ " )
9+
10+ @pytest .mark .skipif (sys .platform != "win32" , reason = "Windows-specific test " )
1111@pytest .mark .parametrize (
1212 "args" ,
1313 [
@@ -32,19 +32,18 @@ async def test_windows_process_creation(args):
3232 # Directly test the fixed function that was causing the hanging issue
3333 try :
3434 # Set a timeout to prevent hanging
35- async with asyncio . timeout (5 ):
35+ with anyio . fail_after (5 ):
3636 # Test the actual process creation function that was fixed
3737 async with stdio_client (params ) as (read , write ):
3838 print ("inside client" )
3939 async with ClientSession (read , write ) as c :
4040 print ("inside ClientSession" )
4141 await c .initialize ()
42-
43- except asyncio .TimeoutError :
42+ except TimeoutError :
4443 pytest .xfail ("Process creation timed out, indicating a hang issue" )
45- except ProcessLookupError :
46- pytest .xfail ("Process creation failed with ProcessLookupError" )
4744 except Exception as e :
48- assert "ExceptionGroup" in repr (e ), f"Unexpected error: { e } "
49- assert "ProcessLookupError" in repr (e ), f"Unexpected error: { e } "
50- pytest .xfail (f"Expected error: { e } " )
45+ # Simplified exception handling - check for expected errors
46+ if "ProcessLookupError" in repr (e ):
47+ pytest .xfail (f"Expected error: { e } " )
48+ else :
49+ raise
0 commit comments