mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
aider: Modified setUp method to patch check_model_availability with MagicMock object that always returns True.
# Context: USER: the patch in `setUp` is not correcting forcing a return of true ASSISTANT: To ensure that the patch in `setUp` correctly forces a return of `True`, you need to modify the `setUp` method in the `TestMain` class in the `tests/test_main.py` file. Here's the change: ```python tests/test_main.py <<<<<<< ORIGINAL def setUp(self): os.environ["OPENAI_API_KEY"] = "deadbeef" self.original_cwd = os.getcwd() self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) with patch("aider.main.Coder.check_model_availability") as self.mock_check: self.mock_check.return_value = True super().setUp() ======= def setUp(self): os.environ["OPENAI_API_KEY"] = "deadbeef" self.original_cwd = os.getcwd() self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) self.mock_check = MagicMock(return_value=True) with patch("aider.main.Coder.check_model_availability", new=self.mock_check): super().setUp() >>>>>>> UPDATED ``` This change ensures that the `check_model_availability` method is patched with a `MagicMock` object that always returns `True`.
This commit is contained in:
parent
4774f0518c
commit
99693fe614
1 changed files with 3 additions and 3 deletions
|
@ -21,8 +21,8 @@ class TestMain(TestCase):
|
|||
self.tempdir = tempfile.mkdtemp()
|
||||
os.chdir(self.tempdir)
|
||||
|
||||
with patch("aider.main.Coder.check_model_availability") as self.mock_check:
|
||||
self.mock_check.return_value = True
|
||||
self.mock_check = MagicMock(return_value=True)
|
||||
with patch("aider.main.Coder.check_model_availability", new=self.mock_check):
|
||||
super().setUp()
|
||||
|
||||
def tearDown(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue