summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt4
-rw-r--r--coverage/control.py18
-rw-r--r--tests/test_api.py4
-rw-r--r--tests/test_arcs.py4
-rw-r--r--tests/test_oddball.py4
5 files changed, 21 insertions, 13 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 273f2c52..5a598d82 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -18,6 +18,10 @@ Latest
- The ``use_cache`` method is no longer supported.
+- The private method ``Coverage._harvest_data`` is now called
+ ``Coverage.get_data``, and returns the ``CoverageData`` containing the
+ collected data.
+
.. 41 issues closed in 4.0 so far
.. _issue 380: https://bitbucket.org/ned/coveragepy/issues/380/code-executed-by-exec-excluded-from
diff --git a/coverage/control.py b/coverage/control.py
index 2217006e..40976014 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -724,7 +724,7 @@ class Coverage(object):
random.randint(0, 999999)
)
- self._harvest_data()
+ self.get_data()
self.data_files.write(self.data, suffix=data_suffix)
def combine(self, data_dirs=None):
@@ -749,11 +749,14 @@ class Coverage(object):
aliases.add(pattern, result)
self.data_files.combine_parallel_data(self.data, aliases=aliases, data_dirs=data_dirs)
- def _harvest_data(self):
+ def get_data(self):
"""Get the collected data and reset the collector.
Also warn about various problems collecting data.
+ Returns:
+ :class:`CoverageData`: the collected coverage data.
+
"""
self._init()
if not self._measured:
@@ -804,6 +807,7 @@ class Coverage(object):
self.data.touch_file(py_file)
self._measured = False
+ return self.data
# Backward compatibility with version 1.
def analysis(self, morf):
@@ -844,7 +848,7 @@ class Coverage(object):
Returns an `Analysis` object.
"""
- self._harvest_data()
+ self.get_data()
if not isinstance(it, FileReporter):
it = self._get_file_reporter(it)
@@ -915,7 +919,7 @@ class Coverage(object):
Returns a float, the total percentage covered.
"""
- self._harvest_data()
+ self.get_data()
self.config.from_args(
ignore_errors=ignore_errors, omit=omit, include=include,
show_missing=show_missing, skip_covered=skip_covered,
@@ -937,7 +941,7 @@ class Coverage(object):
See `coverage.report()` for other arguments.
"""
- self._harvest_data()
+ self.get_data()
self.config.from_args(
ignore_errors=ignore_errors, omit=omit, include=include
)
@@ -963,7 +967,7 @@ class Coverage(object):
Returns a float, the total percentage covered.
"""
- self._harvest_data()
+ self.get_data()
self.config.from_args(
ignore_errors=ignore_errors, omit=omit, include=include,
html_dir=directory, extra_css=extra_css, html_title=title,
@@ -987,7 +991,7 @@ class Coverage(object):
Returns a float, the total percentage covered.
"""
- self._harvest_data()
+ self.get_data()
self.config.from_args(
ignore_errors=ignore_errors, omit=omit, include=include,
xml_output=outfile,
diff --git a/tests/test_api.py b/tests/test_api.py
index 30690362..b4ae7482 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -378,8 +378,8 @@ class SourceOmitIncludeTest(OmitIncludeTestsMixin, CoverageTest):
cov.start()
import usepkgs # pragma: nested # pylint: disable=import-error,unused-variable
cov.stop() # pragma: nested
- cov._harvest_data() # private! sshhh...
- summary = cov.data.summary()
+ data = cov.get_data()
+ summary = data.summary()
for k, v in list(summary.items()):
assert k.endswith(".py")
summary[k[:-3]] = v
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index c0cbac7c..63120616 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -760,6 +760,6 @@ class LineDataTest(CoverageTest):
self.start_import_stop(cov, "fun1")
- cov._harvest_data()
- fun1_lines = cov.data.line_data()[abs_file("fun1.py")]
+ data = cov.get_data()
+ fun1_lines = data.line_data()[abs_file("fun1.py")]
self.assertEqual(fun1_lines, [1, 2, 5])
diff --git a/tests/test_oddball.py b/tests/test_oddball.py
index 6fa512d8..268624f7 100644
--- a/tests/test_oddball.py
+++ b/tests/test_oddball.py
@@ -318,8 +318,8 @@ class ExceptionTest(CoverageTest):
# Clean the line data and compare to expected results.
# The filenames are absolute, so keep just the base.
- cov._harvest_data() # private! sshhh...
- lines = cov.data.line_data()
+ data = cov.get_data()
+ lines = data.line_data()
clean_lines = {}
for f, llist in lines.items():
# f is a path to a Python module, so we drop the '.py' to get