@@ -80,9 +80,7 @@ def run_server_with_transport(module_name: str, port: int, transport: str) -> No
8080 import sys
8181
8282 # Add examples/snippets to Python path for multiprocessing context
83- snippets_path = os .path .join (
84- os .path .dirname (__file__ ), ".." , ".." , ".." , "examples" , "snippets"
85- )
83+ snippets_path = os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , "examples" , "snippets" )
8684 sys .path .insert (0 , os .path .abspath (snippets_path ))
8785
8886 # Import the servers module in the multiprocessing context
@@ -131,9 +129,7 @@ def run_server_with_transport(module_name: str, port: int, transport: str) -> No
131129 else :
132130 raise ValueError (f"Invalid transport for test server: { transport } " )
133131
134- server = uvicorn .Server (
135- config = uvicorn .Config (app = app , host = "127.0.0.1" , port = port , log_level = "error" )
136- )
132+ server = uvicorn .Server (config = uvicorn .Config (app = app , host = "127.0.0.1" , port = port , log_level = "error" ))
137133 print (f"Starting { transport } server on port { port } " )
138134 server .run ()
139135
@@ -173,9 +169,7 @@ def server_transport(request, server_port: int) -> Generator[str, None, None]:
173169 time .sleep (delay )
174170 attempt += 1
175171 else :
176- raise RuntimeError (
177- f"Server failed to start after { max_attempts } attempts (port { server_port } )"
178- )
172+ raise RuntimeError (f"Server failed to start after { max_attempts } attempts (port { server_port } )" )
179173
180174 yield transport
181175
@@ -352,14 +346,10 @@ async def test_basic_prompts(server_transport: str, server_url: str) -> None:
352346
353347 # Test review_code prompt
354348 prompts = await session .list_prompts ()
355- review_prompt = next (
356- (p for p in prompts .prompts if p .name == "review_code" ), None
357- )
349+ review_prompt = next ((p for p in prompts .prompts if p .name == "review_code" ), None )
358350 assert review_prompt is not None
359351
360- prompt_result = await session .get_prompt (
361- "review_code" , {"code" : "def hello():\n print('Hello')" }
362- )
352+ prompt_result = await session .get_prompt ("review_code" , {"code" : "def hello():\n print('Hello')" })
363353 assert isinstance (prompt_result , GetPromptResult )
364354 assert len (prompt_result .messages ) == 1
365355 assert isinstance (prompt_result .messages [0 ].content , TextContent )
@@ -415,18 +405,16 @@ async def test_tool_progress(server_transport: str, server_url: str) -> None:
415405 assert result .capabilities .tools is not None
416406
417407 # Test long_running_task tool that reports progress
418- tool_result = await session .call_tool (
419- "long_running_task" , {"task_name" : "test" , "steps" : 3 }
420- )
408+ tool_result = await session .call_tool ("long_running_task" , {"task_name" : "test" , "steps" : 3 })
421409 assert len (tool_result .content ) == 1
422410 assert isinstance (tool_result .content [0 ], TextContent )
423411 assert "Task 'test' completed" in tool_result .content [0 ].text
424412
425413 # Verify that progress notifications or log messages were sent
426414 # Progress can come through either progress notifications or log messages
427- total_notifications = len (
428- notification_collector .progress_notifications
429- ) + len ( notification_collector . log_messages )
415+ total_notifications = len (notification_collector . progress_notifications ) + len (
416+ notification_collector .log_messages
417+ )
430418 assert total_notifications > 0
431419
432420
@@ -447,9 +435,7 @@ async def test_sampling(server_transport: str, server_url: str) -> None:
447435
448436 async with client_cm as client_streams :
449437 read_stream , write_stream = unpack_streams (client_streams )
450- async with ClientSession (
451- read_stream , write_stream , sampling_callback = sampling_callback
452- ) as session :
438+ async with ClientSession (read_stream , write_stream , sampling_callback = sampling_callback ) as session :
453439 # Test initialization
454440 result = await session .initialize ()
455441 assert isinstance (result , InitializeResult )
@@ -480,9 +466,7 @@ async def test_elicitation(server_transport: str, server_url: str) -> None:
480466
481467 async with client_cm as client_streams :
482468 read_stream , write_stream = unpack_streams (client_streams )
483- async with ClientSession (
484- read_stream , write_stream , elicitation_callback = elicitation_callback
485- ) as session :
469+ async with ClientSession (read_stream , write_stream , elicitation_callback = elicitation_callback ) as session :
486470 # Test initialization
487471 result = await session .initialize ()
488472 assert isinstance (result , InitializeResult )
@@ -528,9 +512,7 @@ async def test_completion(server_transport: str, server_url: str) -> None:
528512 assert len (prompts .prompts ) > 0
529513
530514 # Test getting a prompt
531- prompt_result = await session .get_prompt (
532- "review_code" , {"language" : "python" , "code" : "def test(): pass" }
533- )
515+ prompt_result = await session .get_prompt ("review_code" , {"language" : "python" , "code" : "def test(): pass" })
534516 assert len (prompt_result .messages ) > 0
535517
536518
@@ -642,9 +624,7 @@ async def test_structured_output(server_transport: str, server_url: str) -> None
642624 assert result .serverInfo .name == "Structured Output Example"
643625
644626 # Test get_weather tool
645- weather_result = await session .call_tool (
646- "get_weather" , {"city" : "New York" }
647- )
627+ weather_result = await session .call_tool ("get_weather" , {"city" : "New York" })
648628 assert len (weather_result .content ) == 1
649629 assert isinstance (weather_result .content [0 ], TextContent )
650630
0 commit comments