mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-22 05:14:59 +00:00

# 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 = <tests.test_commands.TestCommands testMethod=test_cmd_add> 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 = <aider.commands.Commands object at 0x107e74210> 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.
23 lines
658 B
Python
23 lines
658 B
Python
import os
|
|
import tempfile
|
|
from unittest import TestCase
|
|
from aider.io import InputOutput
|
|
from aider.coder import Coder
|
|
from aider.commands import Commands
|
|
|
|
class TestCommands(TestCase):
|
|
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')
|
|
|
|
self.assertTrue(os.path.exists('foo.txt'))
|
|
self.assertTrue(os.path.exists('bar.txt'))
|
|
|
|
os.chdir(original_cwd)
|