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: io = IO(pretty=False, yes=True) > coder = Coder(root=tmpdir) E TypeError: Coder.__init__() got an unexpected keyword argument 'root' tests/test_commands.py:13: TypeError =========================== short test summary info ============================ FAILED tests/test_commands.py::TestCommands::test_cmd_add - TypeError: Coder.... ============================== 1 failed in 0.52s =============================== ASSISTANT: It seems like the `Coder` class in `aider/coder.py` does not accept a `root` keyword argument in its `__init__` method. To fix this issue, we need to modify the `__init__` method of the `Coder` class to accept the `root` keyword argument and set it as an instance variable ^C KeyboardInterrupt USER: no, fix the call ASSISTANT: To fix the call to the `Coder` class in `tests/test_commands.py`, we need to remove the `root` keyword argument and pass the required arguments according to the `__init__` method of the `Coder` class. Here's the change you need to make in `tests/test_commands.py`: ```python tests/test_commands.py <<<<<<< ORIGINAL coder = Coder(root=tmpdir) ======= coder = Coder(main_model="gpt-3.5-turbo", fnames=[], pretty=False, show_diffs=False, auto_commits=False, io=io, dry_run=False) >>>>>>> UPDATED ``` This change removes the `root` keyword argument and provides the required arguments for the `Coder` class.
27 lines
1 KiB
Python
27 lines
1 KiB
Python
import os
|
|
import tempfile
|
|
import unittest
|
|
from unittest.mock import MagicMock
|
|
from aider.commands import Commands
|
|
from aider.io import InputOutput as IO
|
|
from aider.coder import Coder
|
|
|
|
class TestCommands(unittest.TestCase):
|
|
def test_cmd_add(self):
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
io = IO(pretty=False, yes=True)
|
|
coder = Coder(main_model="gpt-3.5-turbo", fnames=[], pretty=False, show_diffs=False, auto_commits=False, io=io, dry_run=False)
|
|
commands = Commands(io, coder)
|
|
|
|
# Mock the Confirm.ask method to return True for creating files
|
|
with unittest.mock.patch("rich.prompt.Confirm.ask", return_value=True):
|
|
commands.cmd_add("foo.txt bar.txt")
|
|
|
|
foo_path = os.path.join(tmpdir, "foo.txt")
|
|
bar_path = os.path.join(tmpdir, "bar.txt")
|
|
|
|
self.assertTrue(os.path.exists(foo_path), "foo.txt should be created")
|
|
self.assertTrue(os.path.exists(bar_path), "bar.txt should be created")
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|