Skip to content

Commit c8d7397

Browse files
committed
Split up test_multiple_exit_branches into 3 tests exercising #1852.
1 parent af70eb9 commit c8d7397

File tree

1 file changed

+74
-3
lines changed

1 file changed

+74
-3
lines changed

tests/test_lcov.py

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def foo(a):
435435
actual_result = self.get_lcov_report_content()
436436
assert expected_result == actual_result
437437

438-
def test_multiple_exit_branches(self) -> None:
438+
def test_genexpr_exit_arcs_pruned_when_executed(self) -> None:
439439
self.make_file("runme.py", """\
440440
def foo(a):
441441
if any(x > 0 for x in a):
@@ -469,12 +469,83 @@ def foo(a):
469469
"""),
470470
textwrap.dedent("""\
471471
BRDA:2,0,to line 3,1
472-
BRDA:2,0,to exit 1,1
473-
BRDA:2,0,to exit 2,1
472+
BRDA:2,0,to exit,1
474473
BRF:2
475474
BRH:2
476475
end_of_record
477476
"""),
478477
)
479478
actual_result = self.get_lcov_report_content()
480479
assert expected_result == actual_result
480+
481+
def test_genexpr_exit_arcs_pruned_when_missing(self) -> None:
482+
self.make_file("runme.py", """\
483+
def foo(a):
484+
if any(x > 0 for x in a):
485+
print(f"{a!r} has positives")
486+
foo([])
487+
""")
488+
cov = coverage.Coverage(source=".", branch=True)
489+
self.start_import_stop(cov, "runme")
490+
cov.lcov_report()
491+
expected_result = fn_coverage_missing_in_pypy_38(
492+
textwrap.dedent("""\
493+
SF:runme.py
494+
DA:1,1
495+
DA:2,1
496+
DA:3,0
497+
DA:4,1
498+
LF:4
499+
LH:3
500+
"""),
501+
textwrap.dedent("""\
502+
FN:1,3,foo
503+
FNDA:1,foo
504+
FNF:1
505+
FNH:1
506+
"""),
507+
textwrap.dedent("""\
508+
BRDA:2,0,to line 3,0
509+
BRDA:2,0,to exit,1
510+
BRF:2
511+
BRH:1
512+
end_of_record
513+
"""),
514+
)
515+
actual_result = self.get_lcov_report_content()
516+
assert expected_result == actual_result
517+
518+
def test_genexpr_exit_arcs_pruned_when_not_reached(self) -> None:
519+
self.make_file("runme.py", """\
520+
def foo(a):
521+
if any(x > 0 for x in a):
522+
print(f"{a!r} has positives")
523+
""")
524+
cov = coverage.Coverage(source=".", branch=True)
525+
self.start_import_stop(cov, "runme")
526+
cov.lcov_report()
527+
expected_result = fn_coverage_missing_in_pypy_38(
528+
textwrap.dedent("""\
529+
SF:runme.py
530+
DA:1,1
531+
DA:2,0
532+
DA:3,0
533+
LF:3
534+
LH:1
535+
"""),
536+
textwrap.dedent("""\
537+
FN:1,3,foo
538+
FNDA:0,foo
539+
FNF:1
540+
FNH:0
541+
"""),
542+
textwrap.dedent("""\
543+
BRDA:2,0,to line 3,-
544+
BRDA:2,0,to exit,-
545+
BRF:2
546+
BRH:0
547+
end_of_record
548+
"""),
549+
)
550+
actual_result = self.get_lcov_report_content()
551+
assert expected_result == actual_result

0 commit comments

Comments
 (0)