Skip to content

Commit e3f9e7f

Browse files
committed
test: cover trailing-separator and dedup arcs in from_body inject
Close the last uncovered partial branch (empty segment / duplicate in existing-comment merge loop) behind #1852 comment preservation. Signed-off-by: Alex Chen <l46983284@gmail.com>
1 parent 5bebea4 commit e3f9e7f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/unit/test_regressions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,22 @@ def test_inject_from_body_comments_branches_issue_1852():
25262526
" ",
25272527
comment_prefix=" #",
25282528
) == ("from foo import alpha # disabled; nested")
2529+
# empty segment from a trailing ";" in an existing comment is skipped
2530+
assert _inject_from_body_comments(
2531+
"from foo import alpha # nested;",
2532+
["disabled"],
2533+
"\n",
2534+
" ",
2535+
comment_prefix=" #",
2536+
) == ("from foo import alpha # disabled; nested")
2537+
# duplicate body text is not re-appended from the existing comment
2538+
assert _inject_from_body_comments(
2539+
"from foo import alpha # nested",
2540+
["nested", "disabled"],
2541+
"\n",
2542+
" ",
2543+
comment_prefix=" #",
2544+
) == ("from foo import alpha # nested; disabled")
25292545

25302546

25312547
def test_force_single_line_emits_plain_before_as_with_body_comment_issue_1852():

0 commit comments

Comments
 (0)