@@ -89,9 +89,7 @@ def run_server_with_transport(module_name: str, port: int, transport: str) -> No
8989 import os
9090
9191 # Add examples/snippets to Python path for multiprocessing context
92- snippets_path = os .path .join (
93- os .path .dirname (__file__ ), ".." , ".." , ".." , "examples" , "snippets"
94- )
92+ snippets_path = os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , "examples" , "snippets" )
9593 sys .path .insert (0 , os .path .abspath (snippets_path ))
9694
9795 # Import the servers module in the multiprocessing context
@@ -140,9 +138,7 @@ def run_server_with_transport(module_name: str, port: int, transport: str) -> No
140138 else :
141139 raise ValueError (f"Invalid transport for test server: { transport } " )
142140
143- server = uvicorn .Server (
144- config = uvicorn .Config (app = app , host = "127.0.0.1" , port = port , log_level = "error" )
145- )
141+ server = uvicorn .Server (config = uvicorn .Config (app = app , host = "127.0.0.1" , port = port , log_level = "error" ))
146142 print (f"Starting { transport } server on port { port } " )
147143 server .run ()
148144
@@ -350,14 +346,10 @@ async def test_basic_prompts(server_transport: str, server_url: str) -> None:
350346
351347 # Test review_code prompt
352348 prompts = await session .list_prompts ()
353- review_prompt = next (
354- (p for p in prompts .prompts if p .name == "review_code" ), None
355- )
349+ review_prompt = next ((p for p in prompts .prompts if p .name == "review_code" ), None )
356350 assert review_prompt is not None
357351
358- prompt_result = await session .get_prompt (
359- "review_code" , {"code" : "def hello():\n print('Hello')" }
360- )
352+ prompt_result = await session .get_prompt ("review_code" , {"code" : "def hello():\n print('Hello')" })
361353 assert isinstance (prompt_result , GetPromptResult )
362354 assert len (prompt_result .messages ) == 1
363355 assert isinstance (prompt_result .messages [0 ].content , TextContent )
@@ -413,18 +405,16 @@ async def test_tool_progress(server_transport: str, server_url: str) -> None:
413405 assert result .capabilities .tools is not None
414406
415407 # Test long_running_task tool that reports progress
416- tool_result = await session .call_tool (
417- "long_running_task" , {"task_name" : "test" , "steps" : 3 }
418- )
408+ tool_result = await session .call_tool ("long_running_task" , {"task_name" : "test" , "steps" : 3 })
419409 assert len (tool_result .content ) == 1
420410 assert isinstance (tool_result .content [0 ], TextContent )
421411 assert "Task 'test' completed" in tool_result .content [0 ].text
422412
423413 # Verify that progress notifications or log messages were sent
424414 # Progress can come through either progress notifications or log messages
425- total_notifications = len (
426- notification_collector .progress_notifications
427- ) + len ( notification_collector . log_messages )
415+ total_notifications = len (notification_collector . progress_notifications ) + len (
416+ notification_collector .log_messages
417+ )
428418 assert total_notifications > 0
429419
430420
@@ -445,9 +435,7 @@ async def test_sampling(server_transport: str, server_url: str) -> None:
445435
446436 async with client_cm as client_streams :
447437 read_stream , write_stream = unpack_streams (client_streams )
448- async with ClientSession (
449- read_stream , write_stream , sampling_callback = sampling_callback
450- ) as session :
438+ async with ClientSession (read_stream , write_stream , sampling_callback = sampling_callback ) as session :
451439 # Test initialization
452440 result = await session .initialize ()
453441 assert isinstance (result , InitializeResult )
@@ -478,9 +466,7 @@ async def test_elicitation(server_transport: str, server_url: str) -> None:
478466
479467 async with client_cm as client_streams :
480468 read_stream , write_stream = unpack_streams (client_streams )
481- async with ClientSession (
482- read_stream , write_stream , elicitation_callback = elicitation_callback
483- ) as session :
469+ async with ClientSession (read_stream , write_stream , elicitation_callback = elicitation_callback ) as session :
484470 # Test initialization
485471 result = await session .initialize ()
486472 assert isinstance (result , InitializeResult )
@@ -526,9 +512,7 @@ async def test_completion(server_transport: str, server_url: str) -> None:
526512 assert len (prompts .prompts ) > 0
527513
528514 # Test getting a prompt
529- prompt_result = await session .get_prompt (
530- "review_code" , {"language" : "python" , "code" : "def test(): pass" }
531- )
515+ prompt_result = await session .get_prompt ("review_code" , {"language" : "python" , "code" : "def test(): pass" })
532516 assert len (prompt_result .messages ) > 0
533517
534518
@@ -640,9 +624,7 @@ async def test_structured_output(server_transport: str, server_url: str) -> None
640624 assert result .serverInfo .name == "Structured Output Example"
641625
642626 # Test get_weather tool
643- weather_result = await session .call_tool (
644- "get_weather" , {"city" : "New York" }
645- )
627+ weather_result = await session .call_tool ("get_weather" , {"city" : "New York" })
646628 assert len (weather_result .content ) == 1
647629 assert isinstance (weather_result .content [0 ], TextContent )
648630
0 commit comments