mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
style: Format code with linter and improve import sorting
This commit is contained in:
parent
2ffe49130d
commit
5f694f228f
1 changed files with 18 additions and 13 deletions
|
@ -4,7 +4,11 @@ from unittest.mock import MagicMock, patch
|
|||
from aider.coders.base_coder import Coder
|
||||
from aider.io import InputOutput
|
||||
from aider.models import Model
|
||||
from aider.reasoning_tags import REASONING_TAG, format_reasoning_content, replace_reasoning_tags
|
||||
from aider.reasoning_tags import (
|
||||
REASONING_TAG,
|
||||
format_reasoning_content,
|
||||
replace_reasoning_tags,
|
||||
)
|
||||
|
||||
|
||||
class TestReasoning(unittest.TestCase):
|
||||
|
@ -13,46 +17,47 @@ class TestReasoning(unittest.TestCase):
|
|||
# Setup IO with no streaming, no pretty
|
||||
io = InputOutput(pretty=False, stream=False)
|
||||
io.ai_output = MagicMock()
|
||||
|
||||
|
||||
# Setup model and coder
|
||||
model = Model("gpt-3.5-turbo")
|
||||
coder = Coder.create(model, None, io=io)
|
||||
|
||||
|
||||
# Test data
|
||||
reasoning_content = "My step-by-step reasoning process"
|
||||
main_content = "Final answer after reasoning"
|
||||
|
||||
|
||||
# Mock completion response with reasoning content
|
||||
class MockCompletion:
|
||||
def __init__(self, content, reasoning_content):
|
||||
self.content = content
|
||||
self.reasoning_content = reasoning_content
|
||||
|
||||
|
||||
mock_completion = MockCompletion(main_content, reasoning_content)
|
||||
|
||||
|
||||
# Mock the model's send_completion method
|
||||
with patch.object(model, 'send_completion', return_value=mock_completion):
|
||||
with patch.object(model, "send_completion", return_value=mock_completion):
|
||||
# Call send with a simple message
|
||||
messages = [{"role": "user", "content": "test prompt"}]
|
||||
coder.send(messages)
|
||||
|
||||
|
||||
# Check if ai_output was called with formatted content
|
||||
io.ai_output.assert_called_once()
|
||||
output = io.ai_output.call_args[0][0]
|
||||
|
||||
|
||||
# Output should contain formatted reasoning tags
|
||||
self.assertIn("Thinking ...", output)
|
||||
self.assertIn("... done thinking", output)
|
||||
|
||||
|
||||
# Output should include both reasoning and main content
|
||||
self.assertIn(reasoning_content, output)
|
||||
self.assertIn(main_content, output)
|
||||
|
||||
|
||||
# Ensure proper order: reasoning first, then main content
|
||||
reasoning_pos = output.find(reasoning_content)
|
||||
main_pos = output.find(main_content)
|
||||
self.assertLess(reasoning_pos, main_pos,
|
||||
"Reasoning content should appear before main content")
|
||||
self.assertLess(
|
||||
reasoning_pos, main_pos, "Reasoning content should appear before main content"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue