mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
fix: Add SwitchCoder exception handling in cmd_help
This commit is contained in:
parent
e7c035def4
commit
216ad3b6b5
2 changed files with 8 additions and 8 deletions
|
@ -10,7 +10,7 @@ from unittest import TestCase, mock
|
||||||
import git
|
import git
|
||||||
|
|
||||||
from aider.coders import Coder
|
from aider.coders import Coder
|
||||||
from aider.commands import Commands
|
from aider.commands import Commands, SwitchCoder
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
from aider.io import InputOutput
|
from aider.io import InputOutput
|
||||||
from aider.models import Model
|
from aider.models import Model
|
||||||
|
@ -882,12 +882,6 @@ class TestCommands(TestCase):
|
||||||
mock_run.assert_called_once()
|
mock_run.assert_called_once()
|
||||||
mock_run.assert_called_once_with(question)
|
mock_run.assert_called_once_with(question)
|
||||||
|
|
||||||
self.assertEqual(len(coder.cur_messages), 2)
|
|
||||||
self.assertEqual(coder.cur_messages[0]["role"], "user")
|
|
||||||
self.assertEqual(coder.cur_messages[0]["content"], question)
|
|
||||||
self.assertEqual(coder.cur_messages[1]["role"], "assistant")
|
|
||||||
self.assertEqual(coder.cur_messages[1]["content"], canned_reply)
|
|
||||||
|
|
||||||
def test_cmd_lint_with_dirty_file(self):
|
def test_cmd_lint_with_dirty_file(self):
|
||||||
with GitTemporaryDirectory() as repo_dir:
|
with GitTemporaryDirectory() as repo_dir:
|
||||||
repo = git.Repo(repo_dir)
|
repo = git.Repo(repo_dir)
|
||||||
|
|
|
@ -22,7 +22,13 @@ class TestHelp(unittest.TestCase):
|
||||||
help_coder_run = MagicMock(return_value="")
|
help_coder_run = MagicMock(return_value="")
|
||||||
aider.coders.HelpCoder.run = help_coder_run
|
aider.coders.HelpCoder.run = help_coder_run
|
||||||
|
|
||||||
commands.cmd_help("hi")
|
try:
|
||||||
|
commands.cmd_help("hi")
|
||||||
|
except aider.commands.SwitchCoder:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# If no exception was raised, fail the test
|
||||||
|
assert False, "SwitchCoder exception was not raised"
|
||||||
|
|
||||||
help_coder_run.assert_called_once()
|
help_coder_run.assert_called_once()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue