mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 22:04:59 +00:00
fix: Improve test_commands.py to capture and verify diff output
This commit is contained in:
parent
6d64e88478
commit
edf98d5138
1 changed files with 22 additions and 12 deletions
|
@ -823,21 +823,31 @@ class TestCommands(TestCase):
|
|||
# Run cmd_commit
|
||||
commands.cmd_commit()
|
||||
|
||||
# Modify the file again
|
||||
file_path.write_text("Further modified content")
|
||||
# Capture the output of cmd_diff
|
||||
with mock.patch("builtins.print") as mock_print:
|
||||
commands.cmd_diff("")
|
||||
|
||||
# Run cmd_commit again
|
||||
commands.cmd_commit()
|
||||
# Check if the diff output is correct
|
||||
mock_print.assert_called_with(mock.ANY)
|
||||
diff_output = mock_print.call_args[0][0]
|
||||
self.assertIn("-Initial content", diff_output)
|
||||
self.assertIn("+Modified content", diff_output)
|
||||
|
||||
# Capture the output of cmd_diff
|
||||
with mock.patch("builtins.print") as mock_print:
|
||||
commands.cmd_diff("")
|
||||
# Modify the file again
|
||||
file_path.write_text("Further modified content")
|
||||
|
||||
# Check if the diff output is correct
|
||||
mock_print.assert_called_with(mock.ANY)
|
||||
diff_output = mock_print.call_args[0][0]
|
||||
self.assertIn("-Modified content", diff_output)
|
||||
self.assertIn("+Further modified content", diff_output)
|
||||
# Run cmd_commit again
|
||||
commands.cmd_commit()
|
||||
|
||||
# Capture the output of cmd_diff
|
||||
with mock.patch("builtins.print") as mock_print:
|
||||
commands.cmd_diff("")
|
||||
|
||||
# Check if the diff output is correct
|
||||
mock_print.assert_called_with(mock.ANY)
|
||||
diff_output = mock_print.call_args[0][0]
|
||||
self.assertIn("-Modified content", diff_output)
|
||||
self.assertIn("+Further modified content", diff_output)
|
||||
|
||||
def test_cmd_ask(self):
|
||||
io = InputOutput(pretty=False, yes=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue