From 24f27413695c5179a7c574edd8ac4f9affdb0125 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 3 Aug 2024 10:05:52 -0300 Subject: [PATCH] fix: Simplify mocking in test_commands.py --- tests/basic/test_commands.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/basic/test_commands.py b/tests/basic/test_commands.py index 8d5c50501..508229bc2 100644 --- a/tests/basic/test_commands.py +++ b/tests/basic/test_commands.py @@ -739,15 +739,13 @@ class TestCommands(TestCase): question = "What is the meaning of life?" canned_reply = "The meaning of life is 42." - with mock.patch("aider.coders.Coder.create") as mock_create: - mock_chat_coder = mock.MagicMock() - mock_chat_coder.run.return_value = canned_reply - mock_create.return_value = mock_chat_coder + with mock.patch("aider.coders.Coder.run") as mock_run: + mock_run.return_value = canned_reply commands.cmd_ask(question) - mock_create.assert_called_once() - mock_chat_coder.run.assert_called_once_with(question) + mock_run.assert_called_once() + mock_run.assert_called_once_with(question) self.assertEqual(len(coder.cur_messages), 2) self.assertEqual(coder.cur_messages[0]["role"], "user")