summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-08-11 10:46:41 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-08-11 10:46:41 -0400
commitd0d4fa8415a7a64cebe1e490ec0a38a499de95da (patch)
tree6bc21ba78e24937da109cea152b7ff2cddc64c79
parent0aff68d71faa4938fc28567b0dca1f3413876124 (diff)
downloadpython-coveragepy-git-d0d4fa8415a7a64cebe1e490ec0a38a499de95da.tar.gz
Use @expensive at the FileReporter interface.
-rw-r--r--coverage/parser.py9
-rw-r--r--coverage/python.py7
2 files changed, 8 insertions, 8 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index dc067157..014b4ab5 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -192,6 +192,7 @@ class PythonParser(object):
for (a, b) in arcs
]
+ @expensive
def parse_source(self):
"""Parse source text to find executable lines, excluded lines, etc.
@@ -225,7 +226,6 @@ class PythonParser(object):
return lines, excluded_lines
- @expensive
def arcs(self):
"""Get information about the arcs available in the code.
@@ -233,10 +233,6 @@ class PythonParser(object):
normalized to the first line of multi-line statements.
"""
- return self.arcs_internal()
-
- def arcs_internal(self):
- """Internal worker to calculate the arcs."""
if self._all_arcs is None:
self._all_arcs = []
for l1, l2 in self.byte_parser._all_arcs():
@@ -246,7 +242,6 @@ class PythonParser(object):
self._all_arcs.append((fl1, fl2))
return self._all_arcs
- @expensive
def exit_counts(self):
"""Get a mapping from line numbers to count of exits from that line.
@@ -255,7 +250,7 @@ class PythonParser(object):
"""
excluded_lines = self.first_lines(self.excluded)
exit_counts = collections.defaultdict(int)
- for l1, l2 in self.arcs_internal():
+ for l1, l2 in self.arcs():
if l1 < 0:
# Don't ever report -1 as a line number
continue
diff --git a/coverage/python.py b/coverage/python.py
index e6e9493a..33e6ec01 100644
--- a/coverage/python.py
+++ b/coverage/python.py
@@ -7,7 +7,7 @@ import os.path
import zipimport
from coverage import env, files
-from coverage.misc import contract, NoSource, join_regex
+from coverage.misc import contract, expensive, NoSource, join_regex
from coverage.parser import PythonParser
from coverage.phystokens import source_token_lines, source_encoding
from coverage.plugin import FileReporter
@@ -126,12 +126,14 @@ class PythonFileReporter(FileReporter):
)
return self._parser
+ @expensive
def lines(self):
"""Return the line numbers of statements in the file."""
if self._statements is None:
self._statements, self._excluded = self.parser.parse_source()
return self._statements
+ @expensive
def excluded_lines(self):
"""Return the line numbers of statements in the file."""
if self._excluded is None:
@@ -144,6 +146,7 @@ class PythonFileReporter(FileReporter):
def translate_arcs(self, arcs):
return self.parser.translate_arcs(arcs)
+ @expensive
def no_branch_lines(self):
no_branch = self.parser.lines_matching(
join_regex(self.coverage.config.partial_list),
@@ -151,9 +154,11 @@ class PythonFileReporter(FileReporter):
)
return no_branch
+ @expensive
def arcs(self):
return self.parser.arcs()
+ @expensive
def exit_counts(self):
return self.parser.exit_counts()