mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
aider: The real get_commit_message
is being replaced with a mock function in the test_main_with_empty_git_dir_new_file
test.
# Aider chat conversation: USER: the real `get_commit_message` is being called in `test_main_with_empty_git_dir_new_file` ASSISTANT: To prevent the real `get_commit_message` from being called during the test `test_main_with_empty_git_dir_new_file`, we can use the `unittest.mock.patch` decorator to replace it with a mock function. Here's how to do it: ```python tests/test_main.py <<<<<<< ORIGINAL def test_main_with_empty_git_dir_new_file(self): make_repo() main(["--yes", "foo.txt"], input=DummyInput(), output=DummyOutput()) self.assertTrue(os.path.exists("foo.txt")) ======= @patch("aider.repo.AiderRepo.get_commit_message", return_value="mock commit message") def test_main_with_empty_git_dir_new_file(self, _): make_repo() main(["--yes", "foo.txt"], input=DummyInput(), output=DummyOutput()) self.assertTrue(os.path.exists("foo.txt")) >>>>>>> UPDATED ``` This change will replace the `get_commit_message` method with a mock that always returns "mock commit message" during the execution of `test_main_with_empty_git_dir_new_file`.
This commit is contained in:
parent
dfb106d384
commit
c4a07f1f84
1 changed files with 2 additions and 1 deletions
|
@ -39,7 +39,8 @@ class TestMain(TestCase):
|
|||
main(["foo.txt", "--yes","--no-git"], input=DummyInput(), output=DummyOutput())
|
||||
self.assertTrue(os.path.exists("foo.txt"))
|
||||
|
||||
def test_main_with_empty_git_dir_new_file(self):
|
||||
@patch("aider.repo.AiderRepo.get_commit_message", return_value="mock commit message")
|
||||
def test_main_with_empty_git_dir_new_file(self, _):
|
||||
make_repo()
|
||||
main(["--yes", "foo.txt"], input=DummyInput(), output=DummyOutput())
|
||||
self.assertTrue(os.path.exists("foo.txt"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue