diff options
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index ff395dad..abaa2e50 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -1018,6 +1018,27 @@ class AstArcAnalyzer: return exits @contract(returns='ArcStarts') + def _handle__Match(self, node): + start = self.line_for_node(node) + last_start = start + 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) + last_start = case_start + if not had_wildcard: + exits.add(from_start) + return exits + + @contract(returns='ArcStarts') def _handle__NodeList(self, node): start = self.line_for_node(node) exits = self.add_body_arcs(node.body, from_start=ArcStart(start)) |