aider/tests/test_commands.py
Paul Gauthier 3998bf4c2e aider: Fixed InputOutput instantiation in test_cmd_add.
# 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()
E           TypeError: InputOutput.__init__() missing 2 required positional arguments: 'pretty' and 'yes'

/Users/gauthier/Projects/aider/tests/test_commands.py:14: TypeError
=========================== short test summary info ============================
FAILED tests/test_commands.py::TestCommands::test_cmd_add - TypeError: InputO...
============================== 1 failed in 0.77s ===============================

ASSISTANT: I apologize for the oversight. The `InputOutput` class requires two positional arguments: `pretty` and `yes`. Let's update the test to provide these arguments.

Here's the code change:

```python
tests/test_commands.py
<<<<<<< ORIGINAL
            io = InputOutput()
=======
            io = InputOutput(pretty=True, yes=True)
>>>>>>> UPDATED
```

This should fix the `TypeError` and allow the test to run successfully.
2023-05-19 09:07:56 -07:00

23 lines
663 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)