summaryrefslogtreecommitdiff
path: root/coverage/parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/parser.py')
-rw-r--r--coverage/parser.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index 01b38af3..afe7e574 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -111,7 +111,9 @@ class CodeParser(object):
excluding = True
elif toktype == token.STRING and prev_toktype == token.INDENT:
# Strings that are first on an indented line are docstrings.
- # (a trick from trace.py in the stdlib.)
+ # (a trick from trace.py in the stdlib.) This works for
+ # 99.9999% of cases. For the rest (!) see:
+ # http://stackoverflow.com/questions/1769332/x/1769794#1769794
for i in range(slineno, elineno+1):
self.docstrings.add(i)
elif toktype == token.NEWLINE:
@@ -213,13 +215,18 @@ class CodeParser(object):
exit_counts = {}
for l1, l2 in self.arcs():
if l1 == -1:
+ # Don't ever report -1 as a line number
continue
if l1 in excluded_lines:
+ # Don't report excluded lines as line numbers.
+ continue
+ if l2 in excluded_lines:
+ # Arcs to excluded lines shouldn't count.
continue
if l1 not in exit_counts:
exit_counts[l1] = 0
exit_counts[l1] += 1
-
+
# Class definitions have one extra exit, so remove one for each:
for l in self.classdefs:
# Ensure key is there - #pragma: no cover will mean its not