From 737394f9b65711793fd7716aeca8469590ff9887 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 9 Jun 2023 14:52:37 -0700 Subject: [PATCH] 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. --- tests/test_utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_utils.py b/tests/test_utils.py index 85d736e81..b3660f622 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -201,5 +201,14 @@ These changes replace the `subprocess.run` patches with `subprocess.check_output self.assertEqual(edit_blocks[1][0], "tests/test_repomap.py") + 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()