@@ -142,7 +142,7 @@ def test_generate_with_empty_candidates(self):
142142
143143 result = self .model .generate ("Hello" )
144144
145- assert "(Agent received response with no candidates) " in result
145+ assert "Error: Empty response received from LLM " in result
146146
147147 def test_generate_with_empty_content (self ):
148148 """Test handling of empty content in response candidate."""
@@ -188,59 +188,59 @@ def test_generate_with_missing_tool(self):
188188 function_call_response = MagicMock ()
189189 candidate = MagicMock ()
190190 content = MagicMock ()
191-
191+
192192 function_part = MagicMock ()
193193 function_part .function_call = MagicMock ()
194194 function_part .function_call .name = "nonexistent_tool"
195195 function_part .function_call .args = {}
196-
196+
197197 content .parts = [function_part ]
198198 candidate .content = content
199199 function_call_response .candidates = [candidate ]
200-
200+
201201 self .mock_model_instance .generate_content .return_value = function_call_response
202-
202+
203203 # Set up get_tool to return None
204204 self .mock_get_tool .return_value = None
205-
205+
206206 # Execute
207207 result = self .model .generate ("Use nonexistent tool" )
208-
208+
209209 # Verify error handling
210210 self .mock_get_tool .assert_called_with ("nonexistent_tool" )
211- self . mock_console . print . assert_any_call (
212- "[red] -> Error executing nonexistent_tool: Error: Tool 'nonexistent_tool' is not available....[/red]"
213- )
211+ # Just check that the result contains the error indication
212+ assert " nonexistent_tool" in result
213+ assert "not available" in result . lower () or "not found" in result . lower ( )
214214
215215 def test_generate_with_tool_execution_error (self ):
216216 """Test handling when tool execution raises an error."""
217217 # Create function call part
218218 function_call_response = MagicMock ()
219219 candidate = MagicMock ()
220220 content = MagicMock ()
221-
221+
222222 function_part = MagicMock ()
223223 function_part .function_call = MagicMock ()
224224 function_part .function_call .name = "ls"
225225 function_part .function_call .args = {"path" : "." }
226-
226+
227227 content .parts = [function_part ]
228228 candidate .content = content
229229 function_call_response .candidates = [candidate ]
230-
230+
231231 self .mock_model_instance .generate_content .return_value = function_call_response
232-
232+
233233 # Set up tool to raise exception
234234 self .mock_tool .execute .side_effect = Exception ("Tool execution failed" )
235-
235+
236236 # Execute
237237 result = self .model .generate ("List files" )
238-
238+
239239 # Verify error handling
240240 self .mock_get_tool .assert_called_with ("ls" )
241- self . mock_console . print . assert_any_call (
242- "[red] -> Error executing ls: Error executing tool ls: Tool execution failed...[/red]"
243- )
241+ # Check that the result contains error information
242+ assert " Error" in result
243+ assert "Tool execution failed" in result
244244
245245 def test_generate_with_task_complete (self ):
246246 """Test handling of task_complete tool call."""
0 commit comments