From 5d06cab9e6bf14cf8bedf0c50f819877dc38ea4e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 19 May 2023 09:08:37 -0700 Subject: [PATCH] aider: Fixed cmd_add method to accept string input instead of list. # Context: USER: I ran this command: pytest tests/test_commands.py Which produced this output: ============================= test session starts ============================== platform darwin -- Python 3.11.3, pytest-7.3.1, pluggy-1.0.0 rootdir: /Users/gauthier/Projects/aider collected 1 item tests/test_commands.py F [100%] =================================== FAILURES =================================== __________________________ TestCommands.test_cmd_add ___________________________ self = def test_cmd_add(self): with tempfile.TemporaryDirectory() as tmpdir: original_cwd = os.getcwd() os.chdir(tmpdir) io = InputOutput(pretty=True, yes=True) coder = Coder(io) commands = Commands(io, coder) > commands.cmd_add(['foo.txt', 'bar.txt']) /Users/gauthier/Projects/aider/tests/test_commands.py:18: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = args = ['foo.txt', 'bar.txt'] def cmd_add(self, args): "Add matching files to the chat session" added_fnames = [] files = self.coder.get_all_relative_files() > for word in args.split(): E AttributeError: 'list' object has no attribute 'split' /Users/gauthier/Projects/aider/aider/commands.py:161: AttributeError ----------------------------- Captured stdout call ----------------------------- Files are not in a git repo. No suitable git repo, will not automatically commit edits. Common root directory: /private/var/folders/49/kxrdwwbx0h9bchx99397477c0000gn/T/tmptf5hloir =========================== short test summary info ============================ FAILED tests/test_commands.py::TestCommands::test_cmd_add - AttributeError: '... ============================== 1 failed in 0.73s =============================== ASSISTANT: I apologize for the mistake. The `cmd_add` method expects a string as input, not a list. We need to modify the test to pass the arguments as a single string. Here's the code change: ```python tests/test_commands.py <<<<<<< ORIGINAL commands.cmd_add(['foo.txt', 'bar.txt']) ======= commands.cmd_add('foo.txt bar.txt') >>>>>>> UPDATED ``` This should fix the `AttributeError` and allow the test to run successfully. --- tests/test_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index be4918ae1..74f79e684 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -15,7 +15,7 @@ class TestCommands(TestCase): coder = Coder(io) commands = Commands(io, coder) - commands.cmd_add(['foo.txt', 'bar.txt']) + commands.cmd_add('foo.txt bar.txt') self.assertTrue(os.path.exists('foo.txt')) self.assertTrue(os.path.exists('bar.txt'))