summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst6
-rw-r--r--coverage/html.py8
2 files changed, 10 insertions, 4 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 7dad5589..5a47e4f6 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -9,6 +9,10 @@ Change history for Coverage.py
Unreleased
----------
+- Using the ``--skip-covered`` option on an HTML report with 100% coverage
+ would cause a "No data to report" error, as reported in `issue 549`_. This is
+ now fixed; thanks, Loïc Dachary.
+
- If you started and stopped coverage measurement thousands of times in your
process, you could crash Python with a "Fatal Python error: deallocating
None" error. This is now fixed. Thanks to Alex Groce for the bug report.
@@ -17,6 +21,8 @@ Unreleased
function changed, measurement is likely wrong: None". This was spurious, and
has been suppressed.
+.. _issue 549: https://bitbucket.org/ned/coveragepy/issues/549/skip-covered-with-100-coverage-throws-a-no
+
.. _changes_431:
diff --git a/coverage/html.py b/coverage/html.py
index 4a8c5a5f..fd5a2391 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -105,7 +105,7 @@ class HtmlReporter(Reporter):
self.coverage = cov
self.files = []
- self.files_skip_covered = []
+ self.all_files_nums = []
self.has_arcs = self.coverage.data.has_arcs()
self.status = HtmlStatus()
self.extra_css = None
@@ -138,7 +138,7 @@ class HtmlReporter(Reporter):
# Process all the files.
self.report_files(self.html_file, morfs, self.config.html_dir)
- if not self.files and not self.files_skip_covered:
+ if not self.all_files_nums:
raise CoverageException("No data to report.")
# Write the index file.
@@ -174,12 +174,12 @@ class HtmlReporter(Reporter):
"""Generate an HTML file for one source file."""
# Get the numbers for this file.
nums = analysis.numbers
+ self.all_files_nums.append(nums)
if self.config.skip_covered:
# Don't report on 100% files.
no_missing_lines = (nums.n_missing == 0)
no_missing_branches = (nums.n_partial_branches == 0)
if no_missing_lines and no_missing_branches:
- self.files_skip_covered.append(nums)
return
source = fr.source()
@@ -294,7 +294,7 @@ class HtmlReporter(Reporter):
"""Write the index.html file for this report."""
index_tmpl = Templite(read_data("index.html"), self.template_globals)
- self.totals = sum([f['nums'] for f in self.files] + self.files_skip_covered)
+ self.totals = sum(self.all_files_nums)
html = index_tmpl.render({
'has_arcs': self.has_arcs,