Describe the bug
If the body of a case block inside a match statement is excluded from coverage, the case line is still marked as not covered.
To Reproduce
Code under test - testcase.py:
if 1 != 1:
assert False
match 1:
case 1:
print("all is well")
case _: # reported as uncovered
assert False
Configuration - .coveragerc:
[report]
exclude_lines =
assert False$
Commands:
$ coverage run --source=. -m testcase
all is well
$ coverage report -m
Name Stmts Miss Cover Missing
-------------------------------------------
testcase.py 5 1 80% 7
-------------------------------------------
TOTAL 5 1 80%
I'm using coverage version 7.2.0 with Python 3.10 on Ubuntu Linux 22.04.
Expected behavior
I would expect the exclusion to be propagated to the surrounding block for case blocks similarly to how it does for if blocks.
Note that when enabling branch coverage measurement, the case 1: line is reported as partially covered, but I expect that is a direct consequence of line 8 being considered uncovered, so not a separate issue.
Describe the bug
If the body of a
caseblock inside amatchstatement is excluded from coverage, thecaseline is still marked as not covered.To Reproduce
Code under test -
testcase.py:Configuration -
.coveragerc:Commands:
I'm using
coverageversion 7.2.0 with Python 3.10 on Ubuntu Linux 22.04.Expected behavior
I would expect the exclusion to be propagated to the surrounding block for
caseblocks similarly to how it does forifblocks.Note that when enabling branch coverage measurement, the
case 1:line is reported as partially covered, but I expect that is a direct consequence of line 8 being considered uncovered, so not a separate issue.