Skip to content

Pattern matching with branch coverage shows missing exit #2046

@thtrummer

Description

@thtrummer

Describe the bug
Using pattern matching with branch coverage shows missing exit.

Name         Stmts   Miss Branch BrPart  Cover   Missing
--------------------------------------------------------
example.py       8      0      4      1    92%   5->exit
--------------------------------------------------------
TOTAL            8      0      4      1    92%

To Reproduce

Answer the questions below:

  1. What version of Python are you using?
    Python 3.13.5
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful.
    Coverage.py, version 7.10.6 with C extension
  3. What versions of what packages do you have installed? The output of pip freeze is helpful.
    coverage==7.10.6
  4. What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix.
def fn(value):
    match value:
        case int():
            print('int')
        case str():
            print('str')

fn(1)
fn('hello')
  1. What commands should we run to reproduce the problem? Be specific. Include everything, even git clone, pip install, and so on. Explain like we're five!
coverage run --branch example.py
coverage report -m

Expected behavior
100% coverage

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions