diff options
-rw-r--r-- | coverage/html.py | 6 | ||||
-rw-r--r-- | tests/test_html.py | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/coverage/html.py b/coverage/html.py index 22783ef7..4a8c5a5f 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -105,6 +105,7 @@ class HtmlReporter(Reporter): self.coverage = cov self.files = [] + self.files_skip_covered = [] self.has_arcs = self.coverage.data.has_arcs() self.status = HtmlStatus() self.extra_css = None @@ -137,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: + if not self.files and not self.files_skip_covered: raise CoverageException("No data to report.") # Write the index file. @@ -178,6 +179,7 @@ class HtmlReporter(Reporter): 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() @@ -292,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.totals = sum([f['nums'] for f in self.files] + self.files_skip_covered) html = index_tmpl.render({ 'has_arcs': self.has_arcs, diff --git a/tests/test_html.py b/tests/test_html.py index 1c9fa434..06d59460 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -47,7 +47,7 @@ class HtmlTestHelpers(CoverageTest): self.clean_local_file_imports() cov = coverage.Coverage(**(covargs or {})) self.start_import_stop(cov, "main_file") - cov.html_report(**(htmlargs or {})) + return cov.html_report(**(htmlargs or {})) def remove_html_files(self): """Remove the HTML files created as part of the HTML report.""" @@ -464,6 +464,15 @@ class HtmlTest(HtmlTestHelpers, CoverageTest): self.assert_doesnt_exist("htmlcov/main_file_py.html") self.assert_exists("htmlcov/not_covered_py.html") + def test_report_skip_covered_100(self): + self.make_file("main_file.py", """ + def normal(): + print("z") + normal() + """) + assert self.run_coverage(covargs=dict(source="."), htmlargs=dict(skip_covered=True)) == 100.0 + self.assert_doesnt_exist("htmlcov/main_file_py.html") + def test_report_skip_covered_branches(self): self.make_file("main_file.py", """ import not_covered |