Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/hdx/utilities/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,10 @@ def add_separator_if_needed(text_list):
output.append(text_2)
pos += len(text_2)
text_2 = None
if text_1 and pos_1 == combined_len:
if text_1:
add_separator_if_needed(output)
output.append(text_1)
if text_2 and pos_2 == combined_len:
if text_2:
add_separator_if_needed(output)
output.append(text_2)
a = "".join(output)
Expand Down
17 changes: 17 additions & 0 deletions tests/hdx/utilities/test_matching_no_common_block.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""AI-assisted regression for text loss when no matching block qualifies."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this test into test_matching.py and add a trailing nonmatching text case


import pytest

from hdx.utilities.matching import get_matching_then_nonmatching_text


@pytest.mark.parametrize("separator", ["", "\n\n"])
def test_preserves_both_texts_without_qualifying_match(separator: str) -> None:
texts = [
"Apples grow in the northern orchard.",
"Buses depart every evening from town.",
]

result = get_matching_then_nonmatching_text(texts, separator=separator)

assert result == texts[0] + separator + texts[1]