diff --git a/test_selective_execution.py b/test_selective_execution.py index 1282139f6..8bd687b69 100644 --- a/test_selective_execution.py +++ b/test_selective_execution.py @@ -1,4 +1,3 @@ -import pytest from crewai import Agent, Crew, Task, Process def test_selective_execution_basic(): @@ -41,12 +40,12 @@ def test_selective_execution_basic(): selector = crew.task_selector inputs = {"action": "forecast"} - assert selector(inputs, forecast_task) == True - assert selector(inputs, news_task) == False + assert selector(inputs, forecast_task) is True + assert selector(inputs, news_task) is False inputs = {"action": "news"} - assert selector(inputs, forecast_task) == False - assert selector(inputs, news_task) == True + assert selector(inputs, forecast_task) is False + assert selector(inputs, news_task) is True print("All selective execution tests passed!") @@ -67,7 +66,7 @@ def test_selective_process_validation(): ) try: - crew = Crew( + Crew( agents=[researcher], tasks=[task], process=Process.selective @@ -101,10 +100,10 @@ def test_tag_selector_edge_cases(): selector = Crew.create_tag_selector() - assert selector({}, tagged_task) == True - assert selector({}, untagged_task) == True + assert selector({}, tagged_task) is True + assert selector({}, untagged_task) is True - assert selector({"action": "anything"}, untagged_task) == True + assert selector({"action": "anything"}, untagged_task) is True print("Edge case tests passed!") diff --git a/tests/crew_test.py b/tests/crew_test.py index 98b011ce1..fc63f7805 100644 --- a/tests/crew_test.py +++ b/tests/crew_test.py @@ -1564,8 +1564,8 @@ def test_selective_execution_with_tags(researcher, writer): selector = crew.task_selector inputs = {"action": "forecast"} - assert selector(inputs, forecast_task) == True - assert selector(inputs, news_task) == False + assert selector(inputs, forecast_task) is True + assert selector(inputs, news_task) is False def test_selective_process_type(researcher): @@ -1607,7 +1607,7 @@ def test_selective_execution_no_matching_tasks_error(researcher): selector = crew.task_selector inputs = {"action": "nonexistent"} - assert selector(inputs, task) == False + assert selector(inputs, task) is False def test_selective_process_missing_selector_error(researcher): @@ -1657,11 +1657,11 @@ def test_tag_selector_with_mapping(researcher, writer): selector = crew.task_selector - assert selector({"action": "analyze"}, task1) == True - assert selector({"action": "analyze"}, task2) == False + assert selector({"action": "analyze"}, task1) is True + assert selector({"action": "analyze"}, task2) is False - assert selector({"action": "report"}, task1) == False - assert selector({"action": "report"}, task2) == True + assert selector({"action": "report"}, task1) is False + assert selector({"action": "report"}, task2) is True def test_selective_execution_no_action_executes_all(researcher, writer): @@ -1690,8 +1690,8 @@ def test_selective_execution_no_action_executes_all(researcher, writer): selector = crew.task_selector inputs = {} - assert selector(inputs, task1) == True - assert selector(inputs, task2) == True + assert selector(inputs, task1) is True + assert selector(inputs, task2) is True def test_selective_execution_no_tags_executes_all(researcher, writer): @@ -1717,16 +1717,16 @@ def test_selective_execution_no_tags_executes_all(researcher, writer): # Test that tasks without tags are selected when no action or when action doesn't match selector = crew.task_selector - assert selector({}, task1) == True - assert selector({}, task2) == True + assert selector({}, task1) is True + assert selector({}, task2) is True - assert selector({"action": "anything"}, task1) == True - assert selector({"action": "anything"}, task2) == True + assert selector({"action": "anything"}, task1) is True + assert selector({"action": "anything"}, task2) is True def test_selective_execution_with_invalid_tags(researcher): """Test that invalid tag types raise validation errors.""" - with pytest.raises(ValueError, match="All tags must be strings"): + with pytest.raises(ValueError, match="Input should be a valid string"): Task( description="Test task", expected_output="Test output", diff --git a/tests/test_selective_execution_example.py b/tests/test_selective_execution_example.py index a91e8860f..b84cdd4bc 100644 --- a/tests/test_selective_execution_example.py +++ b/tests/test_selective_execution_example.py @@ -1,6 +1,5 @@ """Example demonstrating selective execution for issue #2941.""" -import pytest from crewai import Agent, Crew, Task, Process @@ -35,11 +34,11 @@ def test_issue_2941_example(): } selector = crew.task_selector - assert selector(inputs, forecast_task) == True - assert selector(inputs, holiday_task) == False - assert selector(inputs, macro_task) == False - assert selector(inputs, news_task) == False - assert selector(inputs, query_task) == False + assert selector(inputs, forecast_task) is True + assert selector(inputs, holiday_task) is False + assert selector(inputs, macro_task) is False + assert selector(inputs, news_task) is False + assert selector(inputs, query_task) is False def test_multiple_actions_example(): @@ -61,14 +60,14 @@ def test_multiple_actions_example(): selector = crew.task_selector - assert selector({"action": "research"}, research_task) == True - assert selector({"action": "research"}, analysis_task) == False - assert selector({"action": "research"}, writing_task) == False + assert selector({"action": "research"}, research_task) is True + assert selector({"action": "research"}, analysis_task) is False + assert selector({"action": "research"}, writing_task) is False - assert selector({"action": "analysis"}, research_task) == False - assert selector({"action": "analysis"}, analysis_task) == True - assert selector({"action": "analysis"}, writing_task) == False + assert selector({"action": "analysis"}, research_task) is False + assert selector({"action": "analysis"}, analysis_task) is True + assert selector({"action": "analysis"}, writing_task) is False - assert selector({"action": "writing"}, research_task) == False - assert selector({"action": "writing"}, analysis_task) == False - assert selector({"action": "writing"}, writing_task) == True + assert selector({"action": "writing"}, research_task) is False + assert selector({"action": "writing"}, analysis_task) is False + assert selector({"action": "writing"}, writing_task) is True