From 354a29f6be35c81b5a5fd7e052082e6c0a59e515 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 06:14:54 -0700 Subject: [PATCH 01/15] copy --- README.md | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index fa11cbc56..e88b78d04 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ It also has features that [help GPT understand and modify larger codebases](http ![aider screencast](assets/screencast.svg) -- [Example chat transcripts](#example-chat-transcripts) - [Getting started](#getting-started) +- [Example chat transcripts](#example-chat-transcripts) - [Features](#features) - [Installation](#installation) - [Usage](#usage) @@ -17,6 +17,19 @@ It also has features that [help GPT understand and modify larger codebases](http - [Tips](#tips) - [Limitations](#limitations) +## Getting started + +``` +$ pip install git+https://github.com/paul-gauthier/aider.git +$ export OPENAI_API_KEY=sk-... +$ aider filename.py + +Added filename.py to the chat +Using git repo: .git + +filename.py> switch the fibonacci function from recursion to iteration +``` + ## Example chat transcripts Here are some example transcripts that show how you can chat with `aider` to write and edit code with GPT-4. @@ -30,22 +43,8 @@ Here are some example transcripts that show how you can chat with `aider` to wri * [**Create a Black Box Test Case**](https://aider.chat/examples/add-test.html): GPT creates a "black box" test case without access to the source of the method being tested, using only a [high level map of the repository based on ctags](https://aider.chat/docs/ctags.html). -* [**Honor the NO_COLOR env var**](https://aider.chat/examples/no-color.html): The user pastes the NO_COLOR spec from no-color.org into the chat, and GPT-4 modifies the application to conform. - You can find more chat transcripts on the [examples page](https://aider.chat/examples/). -## Getting started - -``` -$ pip install git+https://github.com/paul-gauthier/aider.git -$ aider filename.py - -Added filename.py to the chat -Using git repo: .git - -filename.py> switch the fibonacci function from recursion to iteration -``` - ## Features * Chat with GPT-4 about your code by launching `aider` from the command line with set of source files to discuss and edit together. GPT can see and edit the content of those files. From 93dae2c108dd2e9de0b5da11348a0aef6a488cbd Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 06:16:16 -0700 Subject: [PATCH 02/15] copy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e88b78d04..c64a89801 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ which helps it understand and modify large codebases. * From GitHub: `pip install git+https://github.com/paul-gauthier/aider.git` * From your local copy of the repo in develop mode to pick up local edits immediately: `pip install -e .` -2. Set up your OpenAI API key as an environment variable `OPENAI_API_KEY` or by including `openai-api-key: sk-` in an `.aider.config.yml` file (see `aider --help`). +2. Set up your OpenAI API key as an environment variable `OPENAI_API_KEY` or by including `openai-api-key: sk-...` in an `.aider.config.yml` file (see `aider --help`). 3. Optionally, install [universal ctags](https://github.com/universal-ctags/ctags). This is helpful if you plan to work with repositories with more than a handful of files. This allows `aider --ctags` to build a [map of your entire git repo](https://aider.chat/docs/ctags.html) and share it with GPT to help it better understand and modify large codebases. From d95d4d931d76258f7cb637e1e0c3c66877ec0e76 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 06:19:08 -0700 Subject: [PATCH 03/15] copy --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c64a89801..2a168fc94 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,12 @@ It also has features that [help GPT understand and modify larger codebases](http ``` $ pip install git+https://github.com/paul-gauthier/aider.git $ export OPENAI_API_KEY=sk-... -$ aider filename.py +$ aider myapp.py -Added filename.py to the chat +Added myapp.py to the chat Using git repo: .git -filename.py> switch the fibonacci function from recursion to iteration +myapp.py> change the fibonacci function from recursion to iteration ``` ## Example chat transcripts From 1b046e81110b8c940add97fccf3e7c8255ebfb29 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:36:48 -0700 Subject: [PATCH 04/15] aider: Added a new method to check the availability of OpenAI models and called it in the `__init__` method to ensure the `main_model` is available in the list of OpenAI models. # Context: USER: in init, call check the list of available openai models and make sure the `main_model` is in there. if not, print an err msg ASSISTANT: ^C KeyboardInterrupt USER: in init, call check the list of available openai models and make sure the `main_model` is in there. if not, print an err msg ASSISTANT: To check the list of available OpenAI models and make sure the `main_model` is in there, you need to modify the `__init__` method in the `Coder` class. Here's how you can do it: 1. Add a new method `check_model_availability` to the `Coder` class that takes the `main_model` as an argument and checks if it's available in the list of OpenAI models. 2. Call this method in the `__init__` method of the `Coder` class. Here are the changes you need to make: ```python aider/coder.py <<<<<<< ORIGINAL class Coder: abs_fnames = None repo = None last_aider_commit_hash = None last_asked_for_commit_time = 0 def __init__( ======= class Coder: abs_fnames = None repo = None last_aider_commit_hash = None last_asked_for_commit_time = 0 def check_model_availability(self, main_model): available_models = openai.Model.list() model_ids = [model.id for model in available_models['data']] if main_model not in model_ids: raise ValueError(f"Model {main_model} is not available. Please choose from the available models: {model_ids}") def __init__( >>>>>>> UPDATED ``` ```python aider/coder.py <<<<<<< ORIGINAL self.main_model = main_model if main_model == "gpt-3.5-turbo": self.io.tool_error( f"aider doesn't work well with {main_model}, use gpt-4 for best results." ) self.set_repo(fnames) ======= self.check_model_availability(main_model) self.main_model = main_model if main_model == "gpt-3.5-turbo": self.io.tool_error( f"aider doesn't work well with {main_model}, use gpt-4 for best results." ) self.set_repo(fnames) >>>>>>> UPDATED ``` These changes will add a new method `check_model_availability` to the `Coder` class and call it in the `__init__` method to ensure the `main_model` is available in the list of OpenAI models. If not, it will raise a `ValueError` with an appropriate error message. --- aider/coder.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/aider/coder.py b/aider/coder.py index af761d62f..e7763dc07 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -29,6 +29,12 @@ class Coder: last_aider_commit_hash = None last_asked_for_commit_time = 0 + def check_model_availability(self, main_model): + available_models = openai.Model.list() + model_ids = [model.id for model in available_models['data']] + if main_model not in model_ids: + raise ValueError(f"Model {main_model} is not available. Please choose from the available models: {model_ids}") + def __init__( self, io, @@ -64,6 +70,7 @@ class Coder: self.console = Console(force_terminal=True, no_color=True) self.commands = Commands(self.io, self) + self.check_model_availability(main_model) self.main_model = main_model if main_model == "gpt-3.5-turbo": self.io.tool_error( From 1f2aa1a6c8b01aea0cb92a7bc16b400140abbff7 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:39:27 -0700 Subject: [PATCH 05/15] Auto fallback to 3.5 --- aider/coder.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index e7763dc07..acb807813 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -31,9 +31,8 @@ class Coder: def check_model_availability(self, main_model): available_models = openai.Model.list() - model_ids = [model.id for model in available_models['data']] - if main_model not in model_ids: - raise ValueError(f"Model {main_model} is not available. Please choose from the available models: {model_ids}") + model_ids = [model.id for model in available_models["data"]] + return main_model in model_ids def __init__( self, @@ -70,11 +69,16 @@ class Coder: self.console = Console(force_terminal=True, no_color=True) self.commands = Commands(self.io, self) - self.check_model_availability(main_model) + if not self.check_model_availability(main_model): + self.io.tool_error( + f"Your openai key does not support {main_model}, using gpt-3.5-turbo." + ) + main_model = "gpt-3.5-turbo" + self.main_model = main_model if main_model == "gpt-3.5-turbo": self.io.tool_error( - f"aider doesn't work well with {main_model}, use gpt-4 for best results." + f"Aider doesn't work well with {main_model}, use gpt-4 for best results." ) self.set_repo(fnames) From fd70d9d63b065db0cafa7a877dedc20df372fef2 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:42:18 -0700 Subject: [PATCH 06/15] aider: Patched check_for_model_availability to always return True during setUp method execution. # Context: USER: in setup, patch coder.check_for_model_availability to return true ASSISTANT: To patch the `check_for_model_availability` method in the `setUp` method of the `TestMain` class, you can use the `unittest.mock.patch` context manager. Here's the change you need to make in the `tests/test_main.py` file: ```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) ======= from unittest.mock import MagicMock 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.coder.Coder.check_for_model_availability") as mock_check: mock_check.return_value = True self.mock_check = mock_check >>>>>>> UPDATED ``` This will patch the `check_for_model_availability` method to always return `True` during the `setUp` method execution. --- tests/test_main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_main.py b/tests/test_main.py index eb35435dc..a4116679b 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -13,12 +13,18 @@ from aider.main import main class TestMain(TestCase): + from unittest.mock import MagicMock + 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.coder.Coder.check_for_model_availability") as mock_check: + mock_check.return_value = True + self.mock_check = mock_check + def tearDown(self): os.chdir(self.original_cwd) shutil.rmtree(self.tempdir) From 1b49ba6e910bba2b53afd972919ccd549f587dcc Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:45:02 -0700 Subject: [PATCH 07/15] 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) From f4bc22e4fc06570c581ae4c36b19518558e6a485 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:46:42 -0700 Subject: [PATCH 08/15] wip --- tests/test_main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 2645c2ea8..e79d9ef39 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -21,9 +21,8 @@ class TestMain(TestCase): self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) - with patch("aider.coder.Coder.check_model_availability") as mock_check: + with patch("aider.main.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) From c97a0ce30a3ee946ba01e4d3c1d4a782b28af257 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:48:55 -0700 Subject: [PATCH 09/15] wip --- tests/test_main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index e79d9ef39..a972be008 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -21,8 +21,8 @@ class TestMain(TestCase): self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) - with patch("aider.main.Coder.check_model_availability") as mock_check: - mock_check.return_value = True + self.mock_check = patch("aider.main.Coder.check_model_availability") + self.mock_check.return_value = True def tearDown(self): os.chdir(self.original_cwd) From 2b07a334cc6c913e0bc360c8d61b9a071548aa52 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:49:39 -0700 Subject: [PATCH 10/15] aider: Set return value of `check_model_availability` to `True` during test setup. # Context: USER: the patch in `setUp` is not correcting forcing a return of true ASSISTANT: To fix the patch in `setUp`, you need to start the patch and set the return value to `True`. Here's the change you need to make in the `tests/test_main.py` file: ```python tests/test_main.py <<<<<<< ORIGINAL self.mock_check = patch("aider.main.Coder.check_model_availability") self.mock_check.return_value = True ======= with patch("aider.main.Coder.check_model_availability") as self.mock_check: self.mock_check.return_value = True super().setUp() >>>>>>> UPDATED ``` This change will ensure that the `check_model_availability` method returns `True` during the test setup. --- tests/test_main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index a972be008..f2b975227 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -21,8 +21,9 @@ class TestMain(TestCase): self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) - self.mock_check = patch("aider.main.Coder.check_model_availability") + with patch("aider.main.Coder.check_model_availability") as self.mock_check: self.mock_check.return_value = True + super().setUp() def tearDown(self): os.chdir(self.original_cwd) From 4774f0518ceae0cee8a4a35b85a3a49bac49d303 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:49:55 -0700 Subject: [PATCH 11/15] wip --- tests/test_main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index f2b975227..9f54a3426 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -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 + with patch("aider.main.Coder.check_model_availability") as self.mock_check: + self.mock_check.return_value = True super().setUp() def tearDown(self): From 99693fe614ea0043891e784bed37f66c0f5f98fe Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:50:55 -0700 Subject: [PATCH 12/15] 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`. --- 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 9f54a3426..f246e6c21 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.main.Coder.check_model_availability") as self.mock_check: - self.mock_check.return_value = True - super().setUp() + self.mock_check = MagicMock(return_value=True) + with patch("aider.main.Coder.check_model_availability", new=self.mock_check): + super().setUp() def tearDown(self): os.chdir(self.original_cwd) From a5414473d9a3f8ba1a2772686126a93193d22700 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:52:21 -0700 Subject: [PATCH 13/15] wip --- tests/test_main.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index f246e6c21..491d75f51 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -13,26 +13,23 @@ from aider.main import main class TestMain(TestCase): - from unittest.mock import MagicMock - 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() - def tearDown(self): os.chdir(self.original_cwd) shutil.rmtree(self.tempdir) def test_main_with_empty_dir_no_files_on_command(self): - pipe_input = create_input(StringIO("")) - main([], input=pipe_input, output=DummyOutput()) - pipe_input.close() + with patch("aider.main.Coder.check_model_availability") as mock_check: + mock_check.return_value = True + + pipe_input = create_input(StringIO("")) + main([], input=pipe_input, output=DummyOutput()) + pipe_input.close() def test_main_with_empty_dir_new_file(self): pipe_input = create_input(StringIO("")) From 2cc87a4afe1fbcc889b30c11725588133ee91215 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:54:15 -0700 Subject: [PATCH 14/15] aider: Added patch to setUp method and stored mock object as an instance variable. # Context: USER: how can i move the patch to setUp so that it is active for all tests? ASSISTANT: To move the patch to the `setUp` method and make it active for all tests, you can use the `patch` as a context manager in the `setUp` method and store the mock object as an instance variable. Then, in the `tearDown` method, you can stop the patch. Here's how to do it: ```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) def tearDown(self): os.chdir(self.original_cwd) shutil.rmtree(self.tempdir) ======= def setUp(self): os.environ["OPENAI_API_KEY"] = "deadbeef" self.original_cwd = os.getcwd() self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) self.patcher = patch("aider.main.Coder.check_model_availability") self.mock_check = self.patcher.start() self.mock_check.return_value = True def tearDown(self): os.chdir(self.original_cwd) shutil.rmtree(self.tempdir) self.patcher.stop() >>>>>>> UPDATED ``` Now the patch is active for all tests, and you can remove the `with` statement from the `test_main_with_empty_dir_no_files_on_command` method: ```python tests/test_main.py <<<<<<< ORIGINAL def test_main_with_empty_dir_no_files_on_command(self): with patch("aider.main.Coder.check_model_availability") as mock_check: mock_check.return_value = True pipe_input = create_input(StringIO("")) main([], input=pipe_input, output=DummyOutput()) pipe_input.close() ======= def test_main_with_empty_dir_no_files_on_command(self): pipe_input = create_input(StringIO("")) main([], input=pipe_input, output=DummyOutput()) pipe_input.close() >>>>>>> UPDATED ``` --- tests/test_main.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 491d75f51..097063208 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -18,18 +18,19 @@ class TestMain(TestCase): self.original_cwd = os.getcwd() self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) + self.patcher = patch("aider.main.Coder.check_model_availability") + self.mock_check = self.patcher.start() + self.mock_check.return_value = True def tearDown(self): os.chdir(self.original_cwd) shutil.rmtree(self.tempdir) + self.patcher.stop() def test_main_with_empty_dir_no_files_on_command(self): - with patch("aider.main.Coder.check_model_availability") as mock_check: - mock_check.return_value = True - - pipe_input = create_input(StringIO("")) - main([], input=pipe_input, output=DummyOutput()) - pipe_input.close() + pipe_input = create_input(StringIO("")) + main([], input=pipe_input, output=DummyOutput()) + pipe_input.close() def test_main_with_empty_dir_new_file(self): pipe_input = create_input(StringIO("")) From e43a48ee1054da17b5a9521ef961d2a9ca37880c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 1 Jun 2023 08:58:35 -0700 Subject: [PATCH 15/15] patch check_model_availability in tests --- tests/test_coder.py | 10 +++++++++- tests/test_commands.py | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_coder.py b/tests/test_coder.py index 52ffabdb9..f703969e3 100644 --- a/tests/test_coder.py +++ b/tests/test_coder.py @@ -1,11 +1,19 @@ import os import unittest -from unittest.mock import MagicMock +from unittest.mock import MagicMock, patch from aider.coder import Coder class TestCoder(unittest.TestCase): + def setUp(self): + self.patcher = patch("aider.coder.Coder.check_model_availability") + self.mock_check = self.patcher.start() + self.mock_check.return_value = True + + def tearDown(self): + self.patcher.stop() + def test_check_for_file_mentions(self): # Mock the IO object mock_io = MagicMock() diff --git a/tests/test_commands.py b/tests/test_commands.py index 5f3d596d1..223c33acd 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -2,6 +2,7 @@ import os import shutil import tempfile from unittest import TestCase +from unittest.mock import patch from aider.commands import Commands from aider.io import InputOutput @@ -13,10 +14,16 @@ class TestCommands(TestCase): self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) + self.patcher = patch("aider.coder.Coder.check_model_availability") + self.mock_check = self.patcher.start() + self.mock_check.return_value = True + def tearDown(self): os.chdir(self.original_cwd) shutil.rmtree(self.tempdir) + self.patcher.stop() + def test_cmd_add(self): # Initialize the Commands and InputOutput objects io = InputOutput(pretty=False, yes=True)