From 575d1c729dbac0a58077117c0e3820cb9b46e24d Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 2 Jun 2025 18:29:16 +0000 Subject: [PATCH] Fix CI test failures: regex pattern, mock patches, method signature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update regex pattern to handle Docker registry URLs with port numbers - Fix mock patches to target correct import path (crewai_tools.CodeInterpreterTool) - Fix integration test method signature for Crew._prepare_tools() - All Docker image formats now validate correctly including my-registry.com:5000/python:latest Co-Authored-By: João --- src/crewai/agent.py | 2 +- tests/test_agent_custom_execution_image.py | 6 +++--- tests/test_custom_execution_image_integration.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/crewai/agent.py b/src/crewai/agent.py index c65f1a7ef..4adc0ed57 100644 --- a/src/crewai/agent.py +++ b/src/crewai/agent.py @@ -130,7 +130,7 @@ class Agent(BaseAgent): execution_image: Optional[str] = Field( default=None, description="Custom Docker image to use for code execution. If not specified, uses the default image.", - pattern=r"^[a-zA-Z0-9._/-]+(?::[a-zA-Z0-9._-]+)?$", + pattern=r"^[a-zA-Z0-9._/-]+(?:\:[0-9]+)?(?:/[a-zA-Z0-9._/-]+)*(?:\:[a-zA-Z0-9._-]+)?$", ) reasoning: bool = Field( default=False, diff --git a/tests/test_agent_custom_execution_image.py b/tests/test_agent_custom_execution_image.py index 8433a7f10..ccc5ae591 100644 --- a/tests/test_agent_custom_execution_image.py +++ b/tests/test_agent_custom_execution_image.py @@ -29,7 +29,7 @@ def test_agent_without_custom_execution_image(): assert agent.execution_image is None -@patch('crewai.agent.CodeInterpreterTool') +@patch('crewai_tools.CodeInterpreterTool') def test_get_code_execution_tools_with_custom_image(mock_code_interpreter): """Test that get_code_execution_tools passes custom image to CodeInterpreterTool.""" agent = Agent( @@ -48,7 +48,7 @@ def test_get_code_execution_tools_with_custom_image(mock_code_interpreter): ) -@patch('crewai.agent.CodeInterpreterTool') +@patch('crewai_tools.CodeInterpreterTool') def test_get_code_execution_tools_without_custom_image(mock_code_interpreter): """Test that get_code_execution_tools works without custom image.""" agent = Agent( @@ -63,7 +63,7 @@ def test_get_code_execution_tools_without_custom_image(mock_code_interpreter): mock_code_interpreter.assert_called_once_with(unsafe_mode=False) -@patch('crewai.agent.CodeInterpreterTool') +@patch('crewai_tools.CodeInterpreterTool') def test_get_code_execution_tools_with_unsafe_mode_and_custom_image(mock_code_interpreter): """Test that both unsafe_mode and custom image work together.""" agent = Agent( diff --git a/tests/test_custom_execution_image_integration.py b/tests/test_custom_execution_image_integration.py index 1d60058f5..4024fd2bc 100644 --- a/tests/test_custom_execution_image_integration.py +++ b/tests/test_custom_execution_image_integration.py @@ -27,7 +27,7 @@ def test_crew_with_custom_execution_image_integration(mock_code_interpreter_clas tasks=[task] ) - crew._prepare_tools(task, agent) + crew._prepare_tools(agent, task, []) mock_code_interpreter_class.assert_called_with( unsafe_mode=False,