Skip to content

Exclusion of body doesn't propagate to case block #1563

Description

@mthuurne

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.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions