mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-21 12:55:00 +00:00
Modify test_commands.py to mock linter.lint method and assert it was called with the dirty file
This commit is contained in:
parent
05ee45c31f
commit
bb7465e05d
1 changed files with 6 additions and 13 deletions
|
@ -719,20 +719,13 @@ class TestCommands(TestCase):
|
|||
# Modify the file to make it dirty
|
||||
file_path.write_text("def hello():\n print('Hello, World!')\n\n# Dirty line\n")
|
||||
|
||||
# Capture the output
|
||||
captured_output = StringIO()
|
||||
sys.stdout = captured_output
|
||||
# Mock the linter.lint method
|
||||
with unittest.mock.patch.object(coder.linter, "lint") as mock_lint:
|
||||
# Run cmd_lint
|
||||
commands.cmd_lint()
|
||||
|
||||
# Run cmd_lint
|
||||
commands.cmd_lint()
|
||||
|
||||
# Restore stdout
|
||||
sys.stdout = sys.__stdout__
|
||||
|
||||
# Check if the dirty file was detected
|
||||
output = captured_output.getvalue()
|
||||
self.assertIn("test_file.py", output)
|
||||
self.assertIn("Dirty files to lint", output)
|
||||
# Check if the linter was called with the dirty file
|
||||
mock_lint.assert_called_once_with(filename)
|
||||
|
||||
del coder
|
||||
del commands
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue