From 35decf122d9061f76108554cc76d639078699df1 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 28 Mar 2025 20:21:58 -1000 Subject: [PATCH] test: Add test for /model updating default edit format --- tests/basic/test_commands.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/basic/test_commands.py b/tests/basic/test_commands.py index bfd17f374..f2d946b33 100644 --- a/tests/basic/test_commands.py +++ b/tests/basic/test_commands.py @@ -1737,6 +1737,25 @@ class TestCommands(TestCase): ) self.assertEqual(context.exception.kwargs.get("main_model").weak_model.name, "gpt-4") + def test_cmd_model_updates_default_edit_format(self): + io = InputOutput(pretty=False, fancy_input=False, yes=True) + # Use gpt-3.5-turbo (default 'diff') + coder = Coder.create(self.GPT35, None, io) + # Ensure current edit format is the default + self.assertEqual(coder.edit_format, self.GPT35.edit_format) + commands = Commands(io, coder) + + # Mock sanity check to avoid network calls + with mock.patch("aider.models.sanity_check_models"): + # Test switching the main model to gpt-4 (default 'whole') + with self.assertRaises(SwitchCoder) as context: + commands.cmd_model("gpt-4") + + # Check that the SwitchCoder exception contains the correct model configuration + self.assertEqual(context.exception.kwargs.get("main_model").name, "gpt-4") + # Check that the edit format is updated to the new model's default + self.assertEqual(context.exception.kwargs.get("edit_format"), "whole") + def test_cmd_ask(self): io = InputOutput(pretty=False, fancy_input=False, yes=True) coder = Coder.create(self.GPT35, None, io)