From a8fe9cb49146ef14be59709334f8f4238b7a5452 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 20 Jun 2023 17:37:28 -0700 Subject: [PATCH] fixed tests --- tests/{test_utils.py => test_editblock.py} | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) rename tests/{test_utils.py => test_editblock.py} (87%) diff --git a/tests/test_utils.py b/tests/test_editblock.py similarity index 87% rename from tests/test_utils.py rename to tests/test_editblock.py index 2444a4a1f..9c0f7b1e3 100644 --- a/tests/test_utils.py +++ b/tests/test_editblock.py @@ -2,7 +2,7 @@ import unittest -import aider.coders.editblock as utils +from aider.coders import editblock class TestUtils(unittest.TestCase): @@ -12,7 +12,7 @@ class TestUtils(unittest.TestCase): replace = "This is a replaced text." expected_output = "This is a replaced text..\nAnother line of text.\nYet another line.\n" - result = utils.replace_most_similar_chunk(whole, part, replace) + result = editblock.replace_most_similar_chunk(whole, part, replace) self.assertEqual(result, expected_output) def test_replace_most_similar_chunk_not_perfect_match(self): @@ -21,7 +21,7 @@ class TestUtils(unittest.TestCase): replace = "This is a replaced text.\nModified line of text." expected_output = "This is a replaced text.\nModified line of text.\nYet another line." - result = utils.replace_most_similar_chunk(whole, part, replace) + result = editblock.replace_most_similar_chunk(whole, part, replace) self.assertEqual(result, expected_output) def test_strip_quoted_wrapping(self): @@ -29,19 +29,19 @@ class TestUtils(unittest.TestCase): "filename.ext\n```\nWe just want this content\nNot the filename and triple quotes\n```" ) expected_output = "We just want this content\nNot the filename and triple quotes\n" - result = utils.strip_quoted_wrapping(input_text, "filename.ext") + result = editblock.strip_quoted_wrapping(input_text, "filename.ext") self.assertEqual(result, expected_output) def test_strip_quoted_wrapping_no_filename(self): input_text = "```\nWe just want this content\nNot the triple quotes\n```" expected_output = "We just want this content\nNot the triple quotes\n" - result = utils.strip_quoted_wrapping(input_text) + result = editblock.strip_quoted_wrapping(input_text) self.assertEqual(result, expected_output) def test_strip_quoted_wrapping_no_wrapping(self): input_text = "We just want this content\nNot the triple quotes\n" expected_output = "We just want this content\nNot the triple quotes\n" - result = utils.strip_quoted_wrapping(input_text) + result = editblock.strip_quoted_wrapping(input_text) self.assertEqual(result, expected_output) def test_find_original_update_blocks(self): @@ -60,7 +60,7 @@ Tooooo Hope you like it! """ - edits = list(utils.find_original_update_blocks(edit)) + edits = list(editblock.find_original_update_blocks(edit)) self.assertEqual(edits, [("foo.txt", "Two\n", "Tooooo\n")]) def test_find_original_update_blocks_quote_below_filename(self): @@ -79,7 +79,7 @@ Tooooo Hope you like it! """ - edits = list(utils.find_original_update_blocks(edit)) + edits = list(editblock.find_original_update_blocks(edit)) self.assertEqual(edits, [("foo.txt", "Two\n", "Tooooo\n")]) def test_find_original_update_blocks_unclosed(self): @@ -98,7 +98,7 @@ oops! """ with self.assertRaises(ValueError) as cm: - list(utils.find_original_update_blocks(edit)) + list(editblock.find_original_update_blocks(edit)) self.assertIn("Incomplete", str(cm.exception)) def test_find_original_update_blocks_missing_filename(self): @@ -116,7 +116,7 @@ oops! """ with self.assertRaises(ValueError) as cm: - list(utils.find_original_update_blocks(edit)) + list(editblock.find_original_update_blocks(edit)) self.assertIn("filename", str(cm.exception)) def test_find_original_update_blocks_no_final_newline(self): @@ -152,7 +152,7 @@ aider/coder.py >>>>>>> UPDATED""" # Should not raise a ValueError - list(utils.find_original_update_blocks(edit)) + list(editblock.find_original_update_blocks(edit)) def test_incomplete_edit_block_missing_filename(self): edit = """ @@ -195,7 +195,7 @@ tests/test_repomap.py These changes replace the `subprocess.run` patches with `subprocess.check_output` patches in both `test_check_for_ctags_failure` and `test_check_for_ctags_success` tests. """ - edit_blocks = list(utils.find_original_update_blocks(edit)) + edit_blocks = list(editblock.find_original_update_blocks(edit)) self.assertEqual(len(edit_blocks), 2) # 2 edits self.assertEqual(edit_blocks[0][0], "tests/test_repomap.py") self.assertEqual(edit_blocks[1][0], "tests/test_repomap.py") @@ -206,7 +206,7 @@ These changes replace the `subprocess.run` patches with `subprocess.check_output 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) + result = editblock.replace_part_with_missing_leading_whitespace(whole, part, replace) self.assertEqual(result, expected_output)