From 82213596f5301981ea59c3067f8738ff9dd54bbc Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 27 Jul 2021 19:55:26 -0400 Subject: fix: match/case will trace the default case line --- coverage/parser.py | 3 --- tests/test_arcs.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/coverage/parser.py b/coverage/parser.py index ed049685..18458147 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -1022,12 +1022,9 @@ class AstArcAnalyzer: exits = set() had_wildcard = False for case in node.cases: - # The wildcard case doesn't execute the pattern. case_start = self.line_for_node(case.pattern) if isinstance(case.pattern, ast.MatchAs): had_wildcard = True - if case.pattern.name is None: - case_start = self.line_for_node(case.body[0]) self.add_arc(last_start, case_start, "the pattern on line {lineno} always matched") from_start = ArcStart(case_start, cause="the pattern on line {lineno} never matched") exits |= self.add_body_arcs(case.body, from_start=from_start) diff --git a/tests/test_arcs.py b/tests/test_arcs.py index a21074bf..ffdc469d 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -1265,7 +1265,7 @@ class MatchCaseTest(CoverageTest): match = "default" print(match) """, - arcz=".1 12 23 34 49 35 56 69 58 89 91 1.", + arcz=".1 12 23 34 49 35 56 69 57 78 89 91 1.", ) assert self.stdout() == "default\nno go\ngo: n\n" -- cgit v1.2.1