diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-03 17:38:03 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-03 17:38:03 -0400 |
commit | 69e0a37098edba20e24fe8fa80e6960c53e2c3c7 (patch) | |
tree | a4930e93c377e3b4641c61619fdd8f71a1b125a1 /test/test_summary.py | |
parent | 3f9716518f854fc9396f815b1c3a8feb7c7397d4 (diff) | |
download | python-coveragepy-git-69e0a37098edba20e24fe8fa80e6960c53e2c3c7.tar.gz |
The reporting functions now return a float, the total percentage covered.
Diffstat (limited to 'test/test_summary.py')
-rw-r--r-- | test/test_summary.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/test_summary.py b/test/test_summary.py index 71fbb1a6..9db8e4eb 100644 --- a/test/test_summary.py +++ b/test/test_summary.py @@ -209,3 +209,38 @@ class SummaryTest2(CoverageTest): report = re.sub(r"\s+", " ", report) self.assert_("test/modules/pkg1/__init__ 1 0 100%" in report) self.assert_("test/modules/pkg2/__init__ 0 0 100%" in report) + + +class ReportingReturnValue(CoverageTest): + def run_coverage(self): + self.make_file("doit.py", """\ + a = 1 + b = 2 + c = 3 + d = 4 + if a > 10: + f = 6 + g = 7 + """) + + cov = coverage.coverage() + cov.start() + self.import_local_file("doit") + cov.stop() + return cov + + def test_report(self): + cov = self.run_coverage() + repout = StringIO() + val = cov.report(include="*/doit.py") + self.assertAlmostEqual(val, 85.7, 1) + + def test_html(self): + cov = self.run_coverage() + val = cov.html_report(include="*/doit.py") + self.assertAlmostEqual(val, 85.7, 1) + + def test_xml(self): + cov = self.run_coverage() + val = cov.xml_report(include="*/doit.py") + self.assertAlmostEqual(val, 85.7, 1) |