diff options
Diffstat (limited to 'coverage/html.py')
-rw-r--r-- | coverage/html.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/coverage/html.py b/coverage/html.py index 34bf6a6..ed8920f 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -7,6 +7,7 @@ from coverage.backward import pickle from coverage.misc import CoverageException, Hasher from coverage.phystokens import source_token_lines, source_encoding from coverage.report import Reporter +from coverage.results import Numbers from coverage.templite import Templite # Disable pylint msg W0612, because a bunch of variables look unused, but @@ -46,6 +47,7 @@ class HtmlReporter(Reporter): self.directory = None self.template_globals = { 'escape': escape, + 'title': self.config.html_title, '__url__': coverage.__url__, '__version__': coverage.__version__, } @@ -59,6 +61,7 @@ class HtmlReporter(Reporter): self.arcs = self.coverage.data.has_arcs() self.status = HtmlStatus() self.extra_css = None + self.totals = Numbers() def report(self, morfs): """Generate an HTML report for `morfs`. @@ -94,6 +97,8 @@ class HtmlReporter(Reporter): self.make_local_static_report_files() + return self.totals.pc_covered + def make_local_static_report_files(self): """Make local instances of static files for HTML report.""" # The files we provide must always be copied. @@ -157,7 +162,6 @@ class HtmlReporter(Reporter): nums = analysis.numbers missing_branch_arcs = analysis.missing_branch_arcs() - n_par = 0 # accumulated below. arcs = self.arcs # These classes determine which lines are highlighted by default. @@ -182,7 +186,6 @@ class HtmlReporter(Reporter): line_class.append(c_mis) elif self.arcs and lineno in missing_branch_arcs: line_class.append(c_par) - n_par += 1 annlines = [] for b in missing_branch_arcs[lineno]: if b < 0: @@ -229,7 +232,6 @@ class HtmlReporter(Reporter): # Save this file's information for the index file. index_info = { 'nums': nums, - 'par': n_par, 'html_filename': html_filename, 'name': cu.name, } @@ -245,12 +247,15 @@ class HtmlReporter(Reporter): files = self.files arcs = self.arcs - totals = sum([f['nums'] for f in files]) + self.totals = totals = sum([f['nums'] for f in files]) extra_css = self.extra_css + html = index_tmpl.render(locals()) + if sys.version_info < (3, 0): + html = html.decode("utf-8") self.write_html( os.path.join(self.directory, "index.html"), - index_tmpl.render(locals()) + html ) # Write the latest hashes for next time. @@ -358,5 +363,5 @@ def spaceless(html): Get rid of some. """ - html = re.sub(">\s+<p ", ">\n<p ", html) + html = re.sub(r">\s+<p ", ">\n<p ", html) return html |