nedbat/coveragepy (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

coverage-7.3.3 broke pragma: no cover in match-case statement #1713

@tdivis

Description

@tdivis

coverage-7.3.3 released few hours ago broke ignoring whole function by # pragma: no cover when the function contains match..case statement with case condition on multiple lines. My minimum example:

code.py:

def hello(): print("Hello world")

def hello2(a): # pragma: no cover match a: case ("hello one" | "hello two"): print("hello1-2") case "hello three": print("hello3")

test_code.py:

from code import hello from unittest import TestCase

class HelloTest(TestCase): def test_hello(self): hello()

Then run coverage and you'll get report with last two match-case lines uncovered even though the whole function should be ignored.

coverage erase && coverage run --parallel-mode --source=code --branch -m unittest test_code.py && coverage combine && coverage report --show-missing
Hello world
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
Combined data file .coverage.glinall.600.XyruySkx
Name      Stmts   Miss Branch BrPart  Cover   Missing
-----------------------------------------------------
code.py       4      2      2      0    33%   10-11
-----------------------------------------------------
TOTAL         4      2      2      0    33%

Worked fine in coverage-7.3.2.