Fix all failing tests and pytest collection warnings
Fixed MagicMock comparison errors across multiple test suites by: - Adding proper ModelCapabilities mocks with real values instead of MagicMock objects - Updating test_auto_mode.py with correct provider mocking for model availability tests - Updating test_thinking_modes.py with proper capabilities mocking in all thinking mode tests - Updating test_tools.py with proper capabilities mocking for CodeReview and Analyze tools - Fixing test_large_prompt_handling.py by adding proper provider mocking to prevent errors before large prompt detection Fixed pytest collection warnings by: - Renaming TestGenRequest to TestGenerationRequest to avoid pytest collecting it as a test class - Renaming TestGenTool to TestGenerationTool to avoid pytest collecting it as a test class - Updated all imports and references across server.py, tools/__init__.py, and test files All 459 tests now pass without warnings or MagicMock comparison errors. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -149,18 +149,39 @@ class TestLargePromptHandling:
|
||||
@pytest.mark.asyncio
|
||||
async def test_codereview_large_focus(self, large_prompt):
|
||||
"""Test that codereview tool detects large focus_on field."""
|
||||
tool = CodeReviewTool()
|
||||
result = await tool.execute(
|
||||
{
|
||||
"files": ["/some/file.py"],
|
||||
"focus_on": large_prompt,
|
||||
"prompt": "Test code review for validation purposes",
|
||||
}
|
||||
)
|
||||
from unittest.mock import MagicMock
|
||||
from providers.base import ModelCapabilities, ProviderType
|
||||
|
||||
assert len(result) == 1
|
||||
output = json.loads(result[0].text)
|
||||
assert output["status"] == "resend_prompt"
|
||||
tool = CodeReviewTool()
|
||||
|
||||
# Mock provider to avoid MagicMock comparison errors that would prevent large prompt detection
|
||||
with patch.object(tool, "get_model_provider") as mock_get_provider:
|
||||
mock_provider = MagicMock()
|
||||
mock_provider.get_provider_type.return_value = MagicMock(value="google")
|
||||
mock_provider.supports_thinking_mode.return_value = False
|
||||
|
||||
# Set up proper capabilities to avoid MagicMock comparison errors
|
||||
mock_capabilities = ModelCapabilities(
|
||||
provider=ProviderType.GOOGLE,
|
||||
model_name="gemini-2.5-flash-preview-05-20",
|
||||
friendly_name="Test Model",
|
||||
context_window=1048576,
|
||||
supports_function_calling=True,
|
||||
)
|
||||
mock_provider.get_capabilities.return_value = mock_capabilities
|
||||
mock_get_provider.return_value = mock_provider
|
||||
|
||||
result = await tool.execute(
|
||||
{
|
||||
"files": ["/some/file.py"],
|
||||
"focus_on": large_prompt,
|
||||
"prompt": "Test code review for validation purposes",
|
||||
}
|
||||
)
|
||||
|
||||
assert len(result) == 1
|
||||
output = json.loads(result[0].text)
|
||||
assert output["status"] == "resend_prompt"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_review_changes_large_original_request(self, large_prompt):
|
||||
|
||||
Reference in New Issue
Block a user