mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
![]() # Aider chat conversation: USER: @patch("aider.repo.AiderRepo.get_commit_message") is not patching it ASSISTANT: It seems like you're having trouble with the `@patch` decorator not correctly patching the `get_commit_message` method of the `AiderRepo` class in your tests. To help you with this, I need to understand the context better. Could you please provide more details about the issue? Are you getting any error messages? If so, could you share them? USER: in `test_main_with_empty_dir_new_file` i don't want `get_commit_message` to be actually called. just to return a mock value ASSISTANT: The `@patch` decorator from the `unittest.mock` module is used to replace the actual method with a mock method during testing. If `get_commit_message` is still being called, it might be due to the incorrect import path in the `@patch` decorator. In your case, the `@patch` decorator should be used as follows: ```python @patch("aider.repo.AiderRepo.get_commit_message", return_value="commit message!") ``` This will replace the `get_commit_message` method with a mock method that always returns "commit message!". Here is the updated `test_main_with_empty_dir_new_file` method: ```python tests/test_main.py <<<<<<< ORIGINAL @patch("aider.repo.AiderRepo.get_commit_message") def test_main_with_empty_dir_new_file(self, get_commit_message): get_commit_message.return_value = "commit message!" main(["foo.txt", "--yes","--no-git"], input=DummyInput(), output=DummyOutput()) self.assertTrue(os.path.exists("foo.txt")) ======= @patch("aider.repo.AiderRepo.get_commit_message", return_value="commit message!") def test_main_with_empty_dir_new_file(self, get_commit_message): main(["foo.txt", "--yes","--no-git"], input=DummyInput(), output=DummyOutput()) self.assertTrue(os.path.exists("foo.txt")) >>>>>>> UPDATED ``` This change should ensure that the actual `get_commit_message` method is not called during the test. Instead, the mock method will be used, returning the specified mock value. |
||
---|---|---|
.. | ||
__init__.py | ||
test_coder.py | ||
test_commands.py | ||
test_editblock.py | ||
test_io.py | ||
test_main.py | ||
test_models.py | ||
test_repo.py | ||
test_repomap.py | ||
test_sendchat.py | ||
test_wholefile.py | ||
utils.py |