From 1b49ba6e910bba2b53afd972919ccd549f587dcc Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:45:02 -0700 Subject: [PATCH] aider: Fixed the `setUp` method in the `TestMain` class to correctly mock the `check_for_model_availability` method. # Context: USER: E AttributeError: does not have the attribute 'check_for_model_availability' ASSISTANT: It seems like you are trying to access the `check_for_model_availability` method of the `Coder` class, but it is not defined as an instance method. To fix this issue, you need to move the `check_model_availability` method inside the `Coder` class and update the tests accordingly. Here are the changes you need to make: 1. Move the ` ^C KeyboardInterrupt USER: fix the `setUp` ASSISTANT: To fix the `setUp` method in the `TestMain` class, you need to update the way you are mocking the `check_for_model_availability` method. Here are the changes you need to make: 1. Modify the `setUp` method in the `TestMain` class to correctly mock the `check_for_model_availability` method of the `Coder` class. ```python tests/test_main.py <<<<<<< ORIGINAL with patch("aider.coder.Coder.check_for_model_availability") as mock_check: mock_check.return_value = True self.mock_check = mock_check ======= with patch("aider.coder.Coder.check_model_availability") as mock_check: mock_check.return_value = True self.mock_check = mock_check >>>>>>> UPDATED ``` This change will ensure that the `check_for_model_availability` method is correctly mocked during the tests. --- tests/test_main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index a4116679b..2645c2ea8 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -21,9 +21,9 @@ class TestMain(TestCase): self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) - with patch("aider.coder.Coder.check_for_model_availability") as mock_check: - mock_check.return_value = True - self.mock_check = mock_check + with patch("aider.coder.Coder.check_model_availability") as mock_check: + mock_check.return_value = True + self.mock_check = mock_check def tearDown(self): os.chdir(self.original_cwd)