From cf25f3a3fe0474a1878172f3664de42c64461fd0 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 21 Jun 2023 21:39:20 -0700 Subject: [PATCH] aider: Replaced MagicMock with custom mock_send function to set partial_response_content and return False in test_get_commit_message_no_strip_unmatched_quotes. # Context: USER: same for test_get_commit_message_no_strip_unmatched_quotes ASSISTANT: To make the requested change, modify the `test_get_commit_message_no_strip_unmatched_quotes` method in the `tests/test_coder.py` file as follows: ```python tests/test_coder.py <<<<<<< ORIGINAL # Mock the send method to return a tuple with a message and False coder.send = MagicMock(return_value=('a good "commit message"', False)) ======= # Mock the send method to set partial_response_content and return False def mock_send(*args, **kwargs): coder.partial_response_content = 'a good "commit message"' return False coder.send = MagicMock(side_effect=mock_send) >>>>>>> UPDATED ``` This will replace the original `MagicMock` with a custom `mock_send` function that sets `coder.partial_response_content` to the desired commit message and returns `False`. --- tests/test_coder.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_coder.py b/tests/test_coder.py index 0d5ae3575..98d0c4af4 100644 --- a/tests/test_coder.py +++ b/tests/test_coder.py @@ -116,8 +116,12 @@ class TestCoder(unittest.TestCase): # Initialize the Coder object with the mocked IO and mocked repo coder = Coder.create(models.GPT4, None, mock_io, openai_api_key="fake_key") - # Mock the send method to return a tuple with a message and False - coder.send = MagicMock(return_value=('a good "commit message"', False)) + # Mock the send method to set partial_response_content and return False + def mock_send(*args, **kwargs): + coder.partial_response_content = 'a good "commit message"' + return False + + coder.send = MagicMock(side_effect=mock_send) # Call the get_commit_message method with dummy diff and context result = coder.get_commit_message("dummy diff", "dummy context")