@@ -132,10 +132,14 @@ async def test_initialize_timeout(self, transport):
132132 # Simulate timeout during context entry
133133 mock_http_transport .__aenter__ .side_effect = TimeoutError ()
134134
135- result = await transport .initialize ()
135+ # Now expecting TimeoutError to be raised instead of returning False
136+ with pytest .raises (TimeoutError ):
137+ await transport .initialize ()
136138
137- assert result is False
138139 assert transport ._initialized is False
140+ # Check metrics were updated
141+ metrics = transport .get_metrics ()
142+ assert metrics ["connection_errors" ] == 1
139143
140144 @pytest .mark .asyncio
141145 async def test_send_ping_success (self , transport ):
@@ -555,8 +559,14 @@ async def test_initialize_with_exception(self, transport):
555559 "chuk_tool_processor.mcp.transport.http_streamable_transport.ChukHTTPTransport" ,
556560 side_effect = Exception ("Connection error" ),
557561 ):
558- result = await transport .initialize ()
559- assert result is False
562+ # Now expecting Exception to be raised instead of returning False
563+ with pytest .raises (Exception , match = "Connection error" ):
564+ await transport .initialize ()
565+
566+ assert transport ._initialized is False
567+ # Check metrics were updated
568+ metrics = transport .get_metrics ()
569+ assert metrics ["connection_errors" ] == 1
560570
561571 @pytest .mark .asyncio
562572 async def test_send_ping_increments_failures (self , transport ):
@@ -791,8 +801,11 @@ async def test_initialize_connection_error_increments_metric(self, transport):
791801 "chuk_tool_processor.mcp.transport.http_streamable_transport.ChukHTTPTransport" ,
792802 side_effect = Exception ("Connection error" ),
793803 ):
794- result = await transport .initialize ()
795- assert result is False
804+ # Now expecting Exception to be raised instead of returning False
805+ with pytest .raises (Exception , match = "Connection error" ):
806+ await transport .initialize ()
807+
808+ assert transport ._initialized is False
796809 assert transport ._metrics .connection_errors == 1
797810
798811 @pytest .mark .asyncio
0 commit comments