Fix the test_cmd_lint_with_dirty_file test to handle the MagicMock object returned by the lint method.

This commit is contained in:
Paul Gauthier (aider) 2024-07-29 16:46:56 -03:00
parent 24c8363aa8
commit 0a61e83c2b

View file

@ -721,12 +721,18 @@ class TestCommands(TestCase):
# Mock the linter.lint method
with mock.patch.object(coder.linter, "lint") as mock_lint:
# Set up the mock to return an empty string (no lint errors)
mock_lint.return_value = ""
# Run cmd_lint
commands.cmd_lint()
# Check if the linter was called with the dirty file
mock_lint.assert_called_once_with(filename)
# Verify that the file is still dirty after linting
self.assertTrue(repo.is_dirty(filename))
del coder
del commands
del repo