Commit graph

14 commits

Author SHA1 Message Date
Paul Gauthier
f1350f169f refac 2023-06-20 16:59:55 -07:00
Paul Gauthier
737394f9b6 aider: Added a test case for replace_part_with_missing_leading_whitespace function.
# Context:
USER: add a test for `replace_part_with_missing_leading_whitespace`
ASSISTANT: To add a test for `replace_part_with_missing_leading_whitespace`, we will modify the `tests/test_utils.py` file.

```python
tests/test_utils.py
<<<<<<< ORIGINAL
if __name__ == "__main__":
    unittest.main()
=======
    def test_replace_part_with_missing_leading_whitespace(self):
        whole = "    line1\n    line2\n    line3\n"
        part = "line1\nline2"
        replace = "new_line1\nnew_line2"
        expected_output = "    new_line1\n    new_line2\n    line3\n"

        result = utils.replace_part_with_missing_leading_whitespace(whole, part, replace)
        self.assertEqual(result, expected_output)

if __name__ == "__main__":
    unittest.main()
>>>>>>> UPDATED
```

This new test case checks if the `replace_part_with_missing_leading_whitespace` function correctly handles the case when the part and replace blocks have missing leading whitespaces.
2023-06-09 14:52:37 -07:00
Paul Gauthier
ca74eee2f9 Allow GPT to omit the filename from edit blocks, if an earlier block provided it 2023-05-30 11:45:21 -07:00
Paul Gauthier
cdcb8b2e73 check for "missing filename" in valerr 2023-05-29 11:11:52 -07:00
Paul Gauthier
72a59e120c aider: Modified final test to check if a ValueError is raised.
# Context:
USER: the final test SHOULD raise ValueError
ASSISTANT: I understand that you want the final test in `tests/test_utils.py` to raise a `ValueError`. I will modify the test to check for the exception.

```python
tests/test_utils.py
<<<<<<< ORIGINAL
        # Should raise a ValueError!
        list(utils.find_original_update_blocks(edit))
=======
        with self.assertRaises(ValueError):
            list(utils.find_original_update_blocks(edit))
>>>>>>> UPDATED
```

Now, the final test in `tests/test_utils.py` will check if a `ValueError` is raised.
2023-05-29 07:14:42 -07:00
Paul Gauthier
a404698a92 added test_false_incomplete_edit_block 2023-05-29 07:07:08 -07:00
Paul Gauthier
92cd2f3ce6 isort 2023-05-28 22:47:38 -07:00
Paul Gauthier
92e091f5a6 fix bug if ORIG/UPD block is missing trailing newline; added test 2023-05-12 13:30:39 -07:00
Paul Gauthier
d45b7ae752 handle filenames above the triple quotes 2023-05-11 22:59:02 -07:00
Paul Gauthier
3ec7880dc8 added tests 2023-05-11 22:10:21 -07:00
Paul Gauthier
5444b45a93 aider: Added test for ValueError containing the word "Incomplete" in test_find_original_update_blocks_unclosed.
# Context:
USER: in test_find_original_update_blocks_unclosed, assert that it throws a valueerror containing the word "Incomplete"
ASSISTANT: To add the test for ValueError containing the word "Incomplete" in the `test_find_original_update_blocks_unclosed` function, you can use the `assertRaises` context manager and check if the exception message contains the word "Incomplete". Here's the change:

```python
tests/test_utils.py
<<<<<<< ORIGINAL
        utils.find_original_update_blocks(edit)
=======
        with self.assertRaises(ValueError) as cm:
            utils.find_original_update_blocks(edit)
        self.assertIn("Incomplete", str(cm.exception))
>>>>>>> UPDATED
```
2023-05-11 22:08:30 -07:00
Paul Gauthier
684b0e4964 Provide structured errors to GPT if it generates malformed ORIG/UPD blocks 2023-05-11 22:06:02 -07:00
Paul Gauthier
6133eb61c1 fix tests and bug 2023-05-11 17:15:19 -07:00
Paul Gauthier
6dd586c753 init testing 2023-05-11 17:11:22 -07:00
Renamed from aider/test_utils.py (Browse further)