From 67d9951094c7f8cab2641bd10bfbb53d1ee45594 Mon Sep 17 00:00:00 2001 From: khulnasoft-bot <43526132+khulnasoft-bot@users.noreply.github.com> Date: Thu, 30 Jan 2025 03:32:53 +0600 Subject: [PATCH] fix: AssertionError --- pr_insight/algo/utils.py | 4 ++-- tests/health_test/main.py | 2 +- tests/unittest/test_extend_patch.py | 32 +++++++++++++---------------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/pr_insight/algo/utils.py b/pr_insight/algo/utils.py index a218263b..bfe08052 100644 --- a/pr_insight/algo/utils.py +++ b/pr_insight/algo/utils.py @@ -639,8 +639,8 @@ def load_large_diff(filename, new_file_content_str: str, original_file_content_s return "" try: - original_file_content_str = (original_file_content_str or "").rstrip() - new_file_content_str = (new_file_content_str or "").rstrip() + original_file_content_str = (original_file_content_str or "").rstrip() + "\n" + new_file_content_str = (new_file_content_str or "").rstrip() + "\n" diff = difflib.unified_diff(original_file_content_str.splitlines(keepends=True), new_file_content_str.splitlines(keepends=True)) if get_settings().config.verbosity_level >= 2 and show_warning: diff --git a/tests/health_test/main.py b/tests/health_test/main.py index 959f54ad..e6ed9d1c 100644 --- a/tests/health_test/main.py +++ b/tests/health_test/main.py @@ -17,7 +17,7 @@ async def run_async(): - pr_url = os.getenv('TEST_PR_URL', 'https://github.com/Khulnasoft/pr-insight/pull/1385') + pr_url = os.getenv('TEST_PR_URL', 'https://github.com/Khulnasoft/pr-insight/pull/102') get_settings().set("config.git_provider", "github") get_settings().set("config.publish_output", False) diff --git a/tests/unittest/test_extend_patch.py b/tests/unittest/test_extend_patch.py index 02c8910c..9aa745d0 100644 --- a/tests/unittest/test_extend_patch.py +++ b/tests/unittest/test_extend_patch.py @@ -163,24 +163,20 @@ def test_extend_patches_with_extra_lines(self, token_handler, pr_languages): class TestLoadLargeDiff: def test_no_newline(self): patch = load_large_diff("test.py", - """\ - old content 1 - some new content - another line - """, - """ - old content 1 - old content 2""") - - patch_expected="""\ ---- -+++ -@@ -1,3 +1,3 @@ -- old content 1 -- old content 2 -+ old content 1 -+ some new content -+ another line + """old content 1 +some new content +another line +""", + """old content 1 +old content 2""") + + patch_expected = """--- ++++ +@@ -1,2 +1,3 @@ + old content 1 +-old content 2 ++some new content ++another line """ assert patch == patch_expected