mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 15:48:29 +00:00
test: add error handling test cases for crew.test()
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user