mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-21 21:04: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, input_history_file=None, chat_history_file=None) tests/test_commands.py:12: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ aider/io.py:60: in __init__ self.chat_history_file = Path(chat_history_file) /usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py:871: in __new__ self = cls._from_parts(args) /usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py:509: in _from_parts drv, root, parts = self._parse_args(args) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ cls = <class 'pathlib.PosixPath'>, args = (None,) @classmethod def _parse_args(cls, args): # This is useful when you don't want to create an instance, just # canonicalize some constructor arguments. parts = [] for a in args: if isinstance(a, PurePath): parts += a._parts else: > a = os.fspath(a) E TypeError: expected str, bytes or os.PathLike object, not NoneType /usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py:493: TypeError =========================== short test summary info ============================ FAILED tests/test_commands.py::TestCommands::test_cmd_add - TypeError: expect... ============================== 1 failed in 0.53s =============================== ASSISTANT: I apologize for the oversight. The `Path` class from `pathlib` does not accept `None` as an argument. We can use an empty string instead of `None` for `input_history_file` and `chat_history_file` when initializing the `IO` class in the test. ```python tests/test_commands.py <<<<<<< ORIGINAL io = IO(pretty=False, yes=True, input_history_file=None, chat_history_file=None) ======= io = IO(pretty=False, yes=True, input_history_file="", chat_history_file="") >>>>>>> UPDATED ``` This change should fix the `TypeError` when initializing the `IO` class in the test.
27 lines
1,015 B
Python
27 lines
1,015 B
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, input_history_file="", chat_history_file="")
|
|
coder = Coder(root=tmpdir)
|
|
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()
|