diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-07-27 19:55:26 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-07-27 19:55:26 -0400 |
commit | 82213596f5301981ea59c3067f8738ff9dd54bbc (patch) | |
tree | 496c6bac3cdf8b3c6fbe7b475c41fc2915080431 | |
parent | c6d9eb99dfe398bc404509fc8cfc3757bdbe4b89 (diff) | |
download | python-coveragepy-git-82213596f5301981ea59c3067f8738ff9dd54bbc.tar.gz |
fix: match/case will trace the default case line
-rw-r--r-- | coverage/parser.py | 3 | ||||
-rw-r--r-- | tests/test_arcs.py | 2 |
2 files changed, 1 insertions, 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" |