diff options
Diffstat (limited to 'coverage/html.py')
-rw-r--r-- | coverage/html.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/coverage/html.py b/coverage/html.py index b0c61649..186e9d22 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -1,11 +1,12 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt +# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt """HTML reporting for coverage.py.""" import datetime import json import os +import re import shutil import coverage @@ -66,6 +67,7 @@ def read_data(fname): def write_html(fname, html): """Write `html` to `fname`, properly encoded.""" + html = re.sub(r"(\A\s+)|(\s+$)", "", html, flags=re.MULTILINE) with open(fname, "wb") as fout: fout.write(html.encode('ascii', 'xmlcharrefreplace')) @@ -102,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() @@ -167,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): |