mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 05:45:00 +00:00
style: Format code with linter and remove trailing whitespaces
This commit is contained in:
parent
16d7cf7a52
commit
c53833072f
1 changed files with 14 additions and 12 deletions
|
@ -75,30 +75,30 @@ class TestReasoning(unittest.TestCase):
|
||||||
# Setup model and coder
|
# Setup model and coder
|
||||||
model = Model("gpt-3.5-turbo")
|
model = Model("gpt-3.5-turbo")
|
||||||
coder = Coder.create(model, None, io=io, stream=True)
|
coder = Coder.create(model, None, io=io, stream=True)
|
||||||
|
|
||||||
# Ensure the coder shows pretty output
|
# Ensure the coder shows pretty output
|
||||||
coder.show_pretty = MagicMock(return_value=True)
|
coder.show_pretty = MagicMock(return_value=True)
|
||||||
|
|
||||||
# Mock streaming response chunks
|
# Mock streaming response chunks
|
||||||
class MockStreamingChunk:
|
class MockStreamingChunk:
|
||||||
def __init__(self, content=None, reasoning_content=None, finish_reason=None):
|
def __init__(self, content=None, reasoning_content=None, finish_reason=None):
|
||||||
self.choices = [MagicMock()]
|
self.choices = [MagicMock()]
|
||||||
self.choices[0].delta = MagicMock()
|
self.choices[0].delta = MagicMock()
|
||||||
self.choices[0].finish_reason = finish_reason
|
self.choices[0].finish_reason = finish_reason
|
||||||
|
|
||||||
# Set content if provided
|
# Set content if provided
|
||||||
if content is not None:
|
if content is not None:
|
||||||
self.choices[0].delta.content = content
|
self.choices[0].delta.content = content
|
||||||
else:
|
else:
|
||||||
# Need to handle attribute access that would raise AttributeError
|
# Need to handle attribute access that would raise AttributeError
|
||||||
delattr(self.choices[0].delta, 'content')
|
delattr(self.choices[0].delta, "content")
|
||||||
|
|
||||||
# Set reasoning_content if provided
|
# Set reasoning_content if provided
|
||||||
if reasoning_content is not None:
|
if reasoning_content is not None:
|
||||||
self.choices[0].delta.reasoning_content = reasoning_content
|
self.choices[0].delta.reasoning_content = reasoning_content
|
||||||
else:
|
else:
|
||||||
# Need to handle attribute access that would raise AttributeError
|
# Need to handle attribute access that would raise AttributeError
|
||||||
delattr(self.choices[0].delta, 'reasoning_content')
|
delattr(self.choices[0].delta, "reasoning_content")
|
||||||
|
|
||||||
# Create chunks to simulate streaming
|
# Create chunks to simulate streaming
|
||||||
chunks = [
|
chunks = [
|
||||||
|
@ -112,7 +112,7 @@ class TestReasoning(unittest.TestCase):
|
||||||
MockStreamingChunk(content="answer "),
|
MockStreamingChunk(content="answer "),
|
||||||
MockStreamingChunk(content="after reasoning"),
|
MockStreamingChunk(content="after reasoning"),
|
||||||
# End the response
|
# End the response
|
||||||
MockStreamingChunk(finish_reason="stop")
|
MockStreamingChunk(finish_reason="stop"),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Create a mock hash object
|
# Create a mock hash object
|
||||||
|
@ -127,22 +127,24 @@ class TestReasoning(unittest.TestCase):
|
||||||
|
|
||||||
# Verify mdstream.update was called
|
# Verify mdstream.update was called
|
||||||
mock_mdstream.update.assert_called()
|
mock_mdstream.update.assert_called()
|
||||||
|
|
||||||
# Check the arguments of the final call to update
|
# Check the arguments of the final call to update
|
||||||
final_call = mock_mdstream.update.call_args_list[-1]
|
final_call = mock_mdstream.update.call_args_list[-1]
|
||||||
self.assertTrue(final_call[1]['final'])
|
self.assertTrue(final_call[1]["final"])
|
||||||
final_text = final_call[0][0]
|
final_text = final_call[0][0]
|
||||||
|
|
||||||
# The final text should include both reasoning and main content with proper formatting
|
# The final text should include both reasoning and main content with proper formatting
|
||||||
self.assertIn("> Thinking ...", final_text)
|
self.assertIn("> Thinking ...", final_text)
|
||||||
self.assertIn("My step-by-step reasoning process", final_text)
|
self.assertIn("My step-by-step reasoning process", final_text)
|
||||||
self.assertIn("> ... done thinking", final_text)
|
self.assertIn("> ... done thinking", final_text)
|
||||||
self.assertIn("Final answer after reasoning", final_text)
|
self.assertIn("Final answer after reasoning", final_text)
|
||||||
|
|
||||||
# Ensure proper order: reasoning first, then main content
|
# Ensure proper order: reasoning first, then main content
|
||||||
reasoning_pos = final_text.find("My step-by-step reasoning process")
|
reasoning_pos = final_text.find("My step-by-step reasoning process")
|
||||||
main_pos = final_text.find("Final answer after reasoning")
|
main_pos = final_text.find("Final answer after reasoning")
|
||||||
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"
|
||||||
|
)
|
||||||
|
|
||||||
def test_send_with_think_tags(self):
|
def test_send_with_think_tags(self):
|
||||||
"""Test that <think> tags are properly processed and formatted."""
|
"""Test that <think> tags are properly processed and formatted."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue