diff options
-rw-r--r-- | coverage/cmdline.py | 2 | ||||
-rw-r--r-- | coverage/control.py | 36 | ||||
-rw-r--r-- | coverage/html.py | 6 | ||||
-rw-r--r-- | coverage/summary.py | 3 | ||||
-rw-r--r-- | coverage/xmlreport.py | 3 | ||||
-rw-r--r-- | tests/test_plugins.py | 8 | ||||
-rw-r--r-- | tests/test_summary.py | 2 |
7 files changed, 29 insertions, 31 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 2af30141..fba1112f 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -659,7 +659,7 @@ class CoverageScript(object): print(" %s" % line) elif info == 'data': self.coverage.load() - data = self.coverage.data + data = self.coverage.get_data() print(info_header("data")) print("path: %s" % self.coverage._data_files.filename) if data: diff --git a/coverage/control.py b/coverage/control.py index aa93671c..a5943aa8 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -152,7 +152,7 @@ class Coverage(object): self._warnings = [] # Other instance attributes, set later. - self.data = self._data_files = self._collector = None + self._data = self._data_files = self._collector = None self._plugins = None self._inorout = None self._inorout_class = InOrOut @@ -270,7 +270,7 @@ class Coverage(object): # Create the data file. We do this at construction time so that the # data file will be written into the directory where the process # started rather than wherever the process eventually chdir'd to. - self.data = CoverageData(debug=self._debug) + self._data = CoverageData(debug=self._debug) self._data_files = CoverageDataFiles( basename=self.config.data_file, warn=self._warn, debug=self._debug, ) @@ -395,7 +395,7 @@ class Coverage(object): """Load previously-collected coverage data from the data file.""" self._init() self._collector.reset() - self._data_files.read(self.data) + self._data_files.read(self._data) def start(self): """Start measuring code coverage. @@ -449,7 +449,7 @@ class Coverage(object): """ self._init() self._collector.reset() - self.data.erase() + self._data.erase() self._data_files.erase(parallel=self.config.parallel) def clear_exclude(self, which='exclude'): @@ -502,8 +502,8 @@ class Coverage(object): def save(self): """Save the collected coverage data to the data file.""" self._init() - self.get_data() - self._data_files.write(self.data, suffix=self._data_suffix) + data = self.get_data() + self._data_files.write(data, suffix=self._data_suffix) def combine(self, data_paths=None, strict=False): """Combine together a number of similarly-named coverage data files. @@ -539,7 +539,7 @@ class Coverage(object): aliases.add(pattern, result) self._data_files.combine_parallel_data( - self.data, aliases=aliases, data_paths=data_paths, strict=strict, + self._data, aliases=aliases, data_paths=data_paths, strict=strict, ) def get_data(self): @@ -554,10 +554,10 @@ class Coverage(object): """ self._init() - if self._collector.save_data(self.data): + if self._collector.save_data(self._data): self._post_save_work() - return self.data + return self._data def _post_save_work(self): """After saving data, look for warnings, post-work, etc. @@ -572,15 +572,15 @@ class Coverage(object): self._inorout.warn_unimported_source() # Find out if we got any data. - if not self.data and self._warn_no_data: + if not self._data and self._warn_no_data: self._warn("No data was collected.", slug="no-data-collected") # Find files that were never executed at all. for file_path, plugin_name in self._inorout.find_unexecuted_files(): - self.data.touch_file(file_path, plugin_name) + self._data.touch_file(file_path, plugin_name) if self.config.note: - self.data.add_run_info(note=self.config.note) + self._data.add_run_info(note=self.config.note) # Backward compatibility with version 1. def analysis(self, morf): @@ -621,11 +621,11 @@ class Coverage(object): Returns an `Analysis` object. """ - self.get_data() + data = self.get_data() if not isinstance(it, FileReporter): it = self._get_file_reporter(it) - return Analysis(self.data, it) + return Analysis(data, it) def _get_file_reporter(self, morf): """Get a FileReporter for a module or file name.""" @@ -634,7 +634,7 @@ class Coverage(object): if isinstance(morf, string_class): abs_morf = abs_file(morf) - plugin_name = self.data.file_tracer(abs_morf) + plugin_name = self._data.file_tracer(abs_morf) if plugin_name: plugin = self._plugins.get(plugin_name) @@ -664,7 +664,7 @@ class Coverage(object): """ if not morfs: - morfs = self.data.measured_files() + morfs = self._data.measured_files() # Be sure we have a list. if not isinstance(morfs, (list, tuple)): @@ -696,7 +696,6 @@ class Coverage(object): Returns a float, the total percentage covered. """ - self.get_data() self.config.from_args( ignore_errors=ignore_errors, report_omit=omit, report_include=include, show_missing=show_missing, skip_covered=skip_covered, @@ -718,7 +717,6 @@ class Coverage(object): See :meth:`report` for other arguments. """ - self.get_data() self.config.from_args( ignore_errors=ignore_errors, report_omit=omit, report_include=include ) @@ -745,7 +743,6 @@ class Coverage(object): Returns a float, the total percentage covered. """ - self.get_data() self.config.from_args( ignore_errors=ignore_errors, report_omit=omit, report_include=include, html_dir=directory, extra_css=extra_css, html_title=title, @@ -770,7 +767,6 @@ class Coverage(object): Returns a float, the total percentage covered. """ - self.get_data() self.config.from_args( ignore_errors=ignore_errors, report_omit=omit, report_include=include, xml_output=outfile, diff --git a/coverage/html.py b/coverage/html.py index 65aac9c1..186e9d22 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -104,11 +104,11 @@ class HtmlReporter(Reporter): } self.source_tmpl = Templite(read_data("pyfile.html"), self.template_globals) - self.coverage = cov + self.data = cov.get_data() self.files = [] self.all_files_nums = [] - self.has_arcs = self.coverage.data.has_arcs() + self.has_arcs = self.data.has_arcs() self.status = HtmlStatus() self.extra_css = None self.totals = Numbers() @@ -169,7 +169,7 @@ class HtmlReporter(Reporter): """Compute a hash that changes if the file needs to be re-reported.""" m = Hasher() m.update(source) - self.coverage.data.add_to_hash(fr.filename, m) + self.data.add_to_hash(fr.filename, m) return m.hexdigest() def html_file(self, fr, analysis): diff --git a/coverage/summary.py b/coverage/summary.py index 9fc60676..95afbcf0 100644 --- a/coverage/summary.py +++ b/coverage/summary.py @@ -16,7 +16,8 @@ class SummaryReporter(Reporter): def __init__(self, coverage, config): super(SummaryReporter, self).__init__(coverage, config) - self.branches = coverage.data.has_arcs() + data = coverage.get_data() + self.branches = data.has_arcs() def report(self, morfs, outfile=None): """Writes a report summarizing coverage statistics per module. diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py index 511270f1..5148b54a 100644 --- a/coverage/xmlreport.py +++ b/coverage/xmlreport.py @@ -42,7 +42,8 @@ class XmlReporter(Reporter): self.source_paths.add(files.canonical_filename(src)) self.packages = {} self.xml_out = None - self.has_arcs = coverage.data.has_arcs() + self.data = coverage.get_data() + self.has_arcs = self.data.has_arcs() def report(self, morfs, outfile=None): """Generate a Cobertura-compatible XML report for `morfs`. diff --git a/tests/test_plugins.py b/tests/test_plugins.py index c9a8feae..0987e41a 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -369,19 +369,19 @@ class GoodFileTracerTest(FileTracerTest): _, statements, missing, _ = cov.analysis("foo_7.html") self.assertEqual(statements, [1, 2, 3, 4, 5, 6, 7]) self.assertEqual(missing, [1, 2, 3, 6, 7]) - self.assertIn("foo_7.html", cov.data.line_counts()) + self.assertIn("foo_7.html", cov.get_data().line_counts()) _, statements, missing, _ = cov.analysis("bar_4.html") self.assertEqual(statements, [1, 2, 3, 4]) self.assertEqual(missing, [1, 4]) - self.assertIn("bar_4.html", cov.data.line_counts()) + self.assertIn("bar_4.html", cov.get_data().line_counts()) - self.assertNotIn("quux_5.html", cov.data.line_counts()) + self.assertNotIn("quux_5.html", cov.get_data().line_counts()) _, statements, missing, _ = cov.analysis("uni_3.html") self.assertEqual(statements, [1, 2, 3]) self.assertEqual(missing, [1]) - self.assertIn("uni_3.html", cov.data.line_counts()) + self.assertIn("uni_3.html", cov.get_data().line_counts()) def test_plugin2_with_branch(self): self.make_render_and_caller() diff --git a/tests/test_summary.py b/tests/test_summary.py index adc1fcfa..b2895370 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -771,7 +771,7 @@ class TestSummaryReporterConfiguration(CoverageTest): cov = Coverage() cov.start() cov.stop() # pragma: nested - cov.data = coverage_data + cov._data = coverage_data printer = SummaryReporter(cov, options) destination = StringIO() printer.report([], destination) |