aider/tests
Paul Gauthier 388f603ef9 aider: Created a file 'foo.bad' with non-utf8 characters before calling the 'cmd_add' method.
# Context:
USER: do the todo
ASSISTANT: To complete the TODO, we need to create a file named 'foo.bad' with a non-utf8 encoding. We can use the Python 'codecs' module to create a file with a specific encoding. In this case, we'll use 'iso-8859-15' which is a common encoding that includes characters not present in utf-8.

Here's how to modify the 'test_cmd_add_bad_encoding' method in the 'tests/test_commands.py' file:

```python
tests/test_commands.py
<<<<<<< ORIGINAL
    def test_cmd_add_bad_encoding(self):
        # Initialize the Commands and InputOutput objects
        io = InputOutput(pretty=False, yes=True)
        from aider.coders import Coder

        coder = Coder.create(models.GPT35, None, io, openai_api_key="deadbeef")
        commands = Commands(io, coder)

        # TODO: make a new file foo.bad which will fail to decode as utf-8

        commands.cmd_add("foo.bad")

        self.assertEqual(coder.abs_fnames, set())
=======
    import codecs
    def test_cmd_add_bad_encoding(self):
        # Initialize the Commands and InputOutput objects
        io = InputOutput(pretty=False, yes=True)
        from aider.coders import Coder

        coder = Coder.create(models.GPT35, None, io, openai_api_key="deadbeef")
        commands = Commands(io, coder)

        # Create a new file foo.bad which will fail to decode as utf-8
        with codecs.open('foo.bad', 'w', encoding='iso-8859-15') as f:
            f.write('ÆØÅ')  # Characters not present in utf-8

        commands.cmd_add("foo.bad")

        self.assertEqual(coder.abs_fnames, set())
>>>>>>> UPDATED
```

This will create a file 'foo.bad' with non-utf8 characters before calling the 'cmd_add' method.
2023-07-05 20:57:21 -07:00
..
__init__.py aider: Added empty __init__.py file to tests directory to fix ModuleNotFoundError when running tests. 2023-05-11 17:12:42 -07:00
test_coder.py fix broken test 2023-07-05 17:11:39 -07:00
test_commands.py aider: Created a file 'foo.bad' with non-utf8 characters before calling the 'cmd_add' method. 2023-07-05 20:57:21 -07:00
test_editblock.py fix test after merge 2023-06-23 07:55:03 -07:00
test_io.py fixed file not found in autocompleter, issue #30 2023-07-04 12:38:36 -07:00
test_main.py more robust get_tracked_files with pathlib 2023-07-05 16:55:37 -07:00
test_models.py More Model test cases 2023-06-21 14:13:34 -07:00
test_repomap.py refactor to use io.read_text 2023-07-05 20:46:15 -07:00
test_wholefile.py tests pass on windows 2023-07-05 14:09:31 -07:00