mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 23:58:34 +00:00
Some checks failed
Notify Downstream / notify-downstream (push) Has been cancelled
fix: resolve flaky tests and race conditions in test suite - Fix telemetry/event tests by patching class methods instead of instances - Use unique temp files/directories to prevent CI race conditions - Reset singleton state between tests - Mock embedchain.Client.setup() to prevent JSON corruption - Rename test files to test_*.py convention - Move agent tests to tests/agents directory - Fix repeated tool usage detection - Remove database-dependent tools causing initialization errors
30 lines
796 B
Python
30 lines
796 B
Python
import pytest
|
|
from unittest.mock import MagicMock
|
|
from crewai.agent import Agent
|
|
from crewai.task import Task
|
|
|
|
|
|
class BaseEvaluationMetricsTest:
|
|
@pytest.fixture
|
|
def mock_agent(self):
|
|
agent = MagicMock(spec=Agent)
|
|
agent.id = "test_agent_id"
|
|
agent.role = "Test Agent"
|
|
agent.goal = "Test goal"
|
|
agent.tools = []
|
|
return agent
|
|
|
|
@pytest.fixture
|
|
def mock_task(self):
|
|
task = MagicMock(spec=Task)
|
|
task.description = "Test task description"
|
|
task.expected_output = "Test expected output"
|
|
return task
|
|
|
|
@pytest.fixture
|
|
def execution_trace(self):
|
|
return {
|
|
"thinking": ["I need to analyze this data carefully"],
|
|
"actions": ["Gathered information", "Analyzed data"],
|
|
}
|