summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
Diffstat (limited to 'coverage')
-rw-r--r--coverage/control.py12
-rw-r--r--coverage/html.py4
-rw-r--r--coverage/summary.py2
-rw-r--r--coverage/xmlreport.py3
4 files changed, 17 insertions, 4 deletions
diff --git a/coverage/control.py b/coverage/control.py
index acca99e..006f06b 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -532,13 +532,15 @@ class coverage(object):
match those patterns will be included in the report. Modules matching
`omit` will not be included in the report.
+ Returns a float, the total percentage covered.
+
"""
self.config.from_args(
ignore_errors=ignore_errors, omit=omit, include=include,
show_missing=show_missing,
)
reporter = SummaryReporter(self, self.config)
- reporter.report(morfs, outfile=file)
+ return reporter.report(morfs, outfile=file)
def annotate(self, morfs=None, directory=None, ignore_errors=None,
omit=None, include=None):
@@ -571,13 +573,15 @@ class coverage(object):
See `coverage.report()` for other arguments.
+ Returns a float, the total percentage covered.
+
"""
self.config.from_args(
ignore_errors=ignore_errors, omit=omit, include=include,
html_dir=directory, extra_css=extra_css,
)
reporter = HtmlReporter(self, self.config)
- reporter.report(morfs)
+ return reporter.report(morfs)
def xml_report(self, morfs=None, outfile=None, ignore_errors=None,
omit=None, include=None):
@@ -590,6 +594,8 @@ class coverage(object):
See `coverage.report()` for other arguments.
+ Returns a float, the total percentage covered.
+
"""
self.config.from_args(
ignore_errors=ignore_errors, omit=omit, include=include,
@@ -604,7 +610,7 @@ class coverage(object):
file_to_close = outfile
try:
reporter = XmlReporter(self, self.config)
- reporter.report(morfs, outfile=outfile)
+ return reporter.report(morfs, outfile=outfile)
finally:
if file_to_close:
file_to_close.close()
diff --git a/coverage/html.py b/coverage/html.py
index 34bf6a6..65bc25e 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -94,6 +94,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.
@@ -245,7 +247,7 @@ 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
self.write_html(
diff --git a/coverage/summary.py b/coverage/summary.py
index c8fa5be..03648e5 100644
--- a/coverage/summary.py
+++ b/coverage/summary.py
@@ -82,3 +82,5 @@ class SummaryReporter(Reporter):
if self.config.show_missing:
args += ("",)
outfile.write(fmt_coverage % args)
+
+ return total.pc_covered
diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py
index 03f910c..e062cee 100644
--- a/coverage/xmlreport.py
+++ b/coverage/xmlreport.py
@@ -84,6 +84,9 @@ class XmlReporter(Reporter):
# Use the DOM to write the output file.
outfile.write(self.xml_out.toprettyxml())
+ # Return the total percentage.
+ return 100.0 * (lhits_tot + bhits_tot) / (lnum_tot + bnum_tot)
+
def xml_file(self, cu, analysis):
"""Add to the XML report for a single file."""