@@ -92,9 +92,7 @@ def run_server_with_transport(module_name: str, port: int, transport: str) -> No
9292 import os
9393
9494 # Add examples/snippets to Python path for multiprocessing context
95- snippets_path = os .path .join (
96- os .path .dirname (__file__ ), ".." , ".." , ".." , "examples" , "snippets"
97- )
95+ snippets_path = os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , "examples" , "snippets" )
9896 sys .path .insert (0 , os .path .abspath (snippets_path ))
9997
10098 # Import the servers module in the multiprocessing context
@@ -143,9 +141,7 @@ def run_server_with_transport(module_name: str, port: int, transport: str) -> No
143141 else :
144142 raise ValueError (f"Invalid transport for test server: { transport } " )
145143
146- server = uvicorn .Server (
147- config = uvicorn .Config (app = app , host = "127.0.0.1" , port = port , log_level = "error" )
148- )
144+ server = uvicorn .Server (config = uvicorn .Config (app = app , host = "127.0.0.1" , port = port , log_level = "error" ))
149145 print (f"Starting { transport } server on port { port } " )
150146 server .run ()
151147
@@ -185,9 +181,7 @@ def server_transport(request, server_port: int) -> Generator[str, None, None]:
185181 time .sleep (delay )
186182 attempt += 1
187183 else :
188- raise RuntimeError (
189- f"Server failed to start after { max_attempts } attempts (port { server_port } )"
190- )
184+ raise RuntimeError (f"Server failed to start after { max_attempts } attempts (port { server_port } )" )
191185
192186 yield transport
193187
@@ -358,14 +352,10 @@ async def test_basic_prompts(server_transport: str, server_url: str) -> None:
358352
359353 # Test review_code prompt
360354 prompts = await session .list_prompts ()
361- review_prompt = next (
362- (p for p in prompts .prompts if p .name == "review_code" ), None
363- )
355+ review_prompt = next ((p for p in prompts .prompts if p .name == "review_code" ), None )
364356 assert review_prompt is not None
365357
366- prompt_result = await session .get_prompt (
367- "review_code" , {"code" : "def hello():\n print('Hello')" }
368- )
358+ prompt_result = await session .get_prompt ("review_code" , {"code" : "def hello():\n print('Hello')" })
369359 assert isinstance (prompt_result , GetPromptResult )
370360 assert len (prompt_result .messages ) == 1
371361 assert isinstance (prompt_result .messages [0 ].content , TextContent )
@@ -421,18 +411,16 @@ async def test_tool_progress(server_transport: str, server_url: str) -> None:
421411 assert result .capabilities .tools is not None
422412
423413 # Test long_running_task tool that reports progress
424- tool_result = await session .call_tool (
425- "long_running_task" , {"task_name" : "test" , "steps" : 3 }
426- )
414+ tool_result = await session .call_tool ("long_running_task" , {"task_name" : "test" , "steps" : 3 })
427415 assert len (tool_result .content ) == 1
428416 assert isinstance (tool_result .content [0 ], TextContent )
429417 assert "Task 'test' completed" in tool_result .content [0 ].text
430418
431419 # Verify that progress notifications or log messages were sent
432420 # Progress can come through either progress notifications or log messages
433- total_notifications = len (
434- notification_collector .progress_notifications
435- ) + len ( notification_collector . log_messages )
421+ total_notifications = len (notification_collector . progress_notifications ) + len (
422+ notification_collector .log_messages
423+ )
436424 assert total_notifications > 0
437425
438426
@@ -453,9 +441,7 @@ async def test_sampling(server_transport: str, server_url: str) -> None:
453441
454442 async with client_cm as client_streams :
455443 read_stream , write_stream = unpack_streams (client_streams )
456- async with ClientSession (
457- read_stream , write_stream , sampling_callback = sampling_callback
458- ) as session :
444+ async with ClientSession (read_stream , write_stream , sampling_callback = sampling_callback ) as session :
459445 # Test initialization
460446 result = await session .initialize ()
461447 assert isinstance (result , InitializeResult )
@@ -486,9 +472,7 @@ async def test_elicitation(server_transport: str, server_url: str) -> None:
486472
487473 async with client_cm as client_streams :
488474 read_stream , write_stream = unpack_streams (client_streams )
489- async with ClientSession (
490- read_stream , write_stream , elicitation_callback = elicitation_callback
491- ) as session :
475+ async with ClientSession (read_stream , write_stream , elicitation_callback = elicitation_callback ) as session :
492476 # Test initialization
493477 result = await session .initialize ()
494478 assert isinstance (result , InitializeResult )
@@ -534,9 +518,7 @@ async def test_completion(server_transport: str, server_url: str) -> None:
534518 assert len (prompts .prompts ) > 0
535519
536520 # Test getting a prompt
537- prompt_result = await session .get_prompt (
538- "review_code" , {"language" : "python" , "code" : "def test(): pass" }
539- )
521+ prompt_result = await session .get_prompt ("review_code" , {"language" : "python" , "code" : "def test(): pass" })
540522 assert len (prompt_result .messages ) > 0
541523
542524
@@ -648,9 +630,7 @@ async def test_structured_output(server_transport: str, server_url: str) -> None
648630 assert result .serverInfo .name == "Structured Output Example"
649631
650632 # Test get_weather tool
651- weather_result = await session .call_tool (
652- "get_weather" , {"city" : "New York" }
653- )
633+ weather_result = await session .call_tool ("get_weather" , {"city" : "New York" })
654634 assert len (weather_result .content ) == 1
655635 assert isinstance (weather_result .content [0 ], TextContent )
656636
0 commit comments