From df6cb60ec76cb7956c5803e4d5467d24c92bb572 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 9 Feb 2025 20:58:40 +0000 Subject: [PATCH] test: add error handling test cases for crew.test() Co-Authored-By: Joe Moura --- tests/crew_test.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/crew_test.py b/tests/crew_test.py index 831e1df05..03321b00e 100644 --- a/tests/crew_test.py +++ b/tests/crew_test.py @@ -104,6 +104,32 @@ def test_crew_test_backward_compatibility(): crew.test(n_iterations=1, openai_model_name="gpt-4") # No assertion needed as we just verify it runs without errors +def test_crew_test_with_invalid_llm(): + """Test that Crew.test() properly handles invalid LLM inputs.""" + task = Task( + description="Test task", + expected_output="Test output", + agent=researcher, + ) + crew = Crew(agents=[researcher], tasks=[task]) + + # Test with invalid LLM type + with pytest.raises(ValueError, match="Unsupported LLM type"): + crew.test(n_iterations=1, llm=123) # type: ignore + +def test_crew_test_with_invalid_iterations(): + """Test that Crew.test() validates n_iterations.""" + task = Task( + description="Test task", + expected_output="Test output", + agent=researcher, + ) + crew = Crew(agents=[researcher], tasks=[task]) + + # Test with invalid n_iterations + with pytest.raises(ValueError, match="n_iterations must be greater than 0"): + crew.test(n_iterations=0, llm=MockLLM()) + def test_crew_config_conditional_requirement(): with pytest.raises(ValueError):