summaryrefslogtreecommitdiff
path: root/coverage/html.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-01-11 17:53:17 -0500
committerNed Batchelder <ned@nedbatchelder.com>2017-01-11 17:53:17 -0500
commitcb0da0af9a826adc86c49fd1429e1ab07d91b770 (patch)
treed8a626a35acd0f3e758f2d32d15b8594c5e6b5a8 /coverage/html.py
parent6c8a2e48c9d74f561216557ad5b07da2cae7c245 (diff)
downloadpython-coveragepy-git-cb0da0af9a826adc86c49fd1429e1ab07d91b770.tar.gz
Delete html files when skipping covered files
Diffstat (limited to 'coverage/html.py')
-rw-r--r--coverage/html.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/coverage/html.py b/coverage/html.py
index fd5a2391..b0c61649 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -12,7 +12,7 @@ import coverage
from coverage import env
from coverage.backward import iitems
from coverage.files import flat_rootname
-from coverage.misc import CoverageException, Hasher, isolate_module
+from coverage.misc import CoverageException, file_be_gone, Hasher, isolate_module
from coverage.report import Reporter
from coverage.results import Numbers
from coverage.templite import Templite
@@ -172,20 +172,26 @@ class HtmlReporter(Reporter):
def html_file(self, fr, analysis):
"""Generate an HTML file for one source file."""
+ rootname = flat_rootname(fr.relative_filename())
+ html_filename = rootname + ".html"
+ html_path = os.path.join(self.directory, html_filename)
+
# 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:
+ # If there's an existing file, remove it.
+ file_be_gone(html_path)
return
source = fr.source()
# Find out if the file on disk is already correct.
- rootname = flat_rootname(fr.relative_filename())
this_hash = self.file_hash(source.encode('utf-8'), fr)
that_hash = self.status.file_hash(rootname)
if this_hash == that_hash:
@@ -277,8 +283,6 @@ class HtmlReporter(Reporter):
'time_stamp': self.time_stamp,
})
- html_filename = rootname + ".html"
- html_path = os.path.join(self.directory, html_filename)
write_html(html_path, html)
# Save this file's information for the index file.