From 341e737bd5010ffd794b029b3051a7ae210bfef2 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 21 Sep 2019 07:21:05 -0400 Subject: Exit arcs have to be corrected to first lines We've long remapped line numbers to the first line of a multi-line statement. But exit line numbers (negative numbers) were not remapped. This meant we were needlessly chasing weirdnesses in implementations. But the actual results of running coverage always remapped results to the first line, so there's no point in tracking the unmapped line numbers in our tests. --- coverage/parser.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'coverage/parser.py') diff --git a/coverage/parser.py b/coverage/parser.py index 12c2d0a5..f0d378c6 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -207,7 +207,11 @@ class PythonParser(object): def first_line(self, line): """Return the first line number of the statement including `line`.""" - return self._multiline.get(line, line) + if line < 0: + line = -self._multiline.get(-line, -line) + else: + line = self._multiline.get(line, line) + return line def first_lines(self, lines): """Map the line numbers in `lines` to the correct first line of the -- cgit v1.2.1