summaryrefslogtreecommitdiff
path: root/test/test_api.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-08-02 22:25:30 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-08-02 22:25:30 -0400
commit37850e04b59675a7292f8b6b810c932be0b4939d (patch)
treee0482d29ec9862cda5a0258031c7c0c58bee6943 /test/test_api.py
parent3436d05a5f5b8c081946b1764d1411aa3bb83806 (diff)
downloadpython-coveragepy-git-37850e04b59675a7292f8b6b810c932be0b4939d.tar.gz
The number of missed branches reported on the HTML summary page didn't match the number on the file page.
Diffstat (limited to 'test/test_api.py')
-rw-r--r--test/test_api.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/test_api.py b/test/test_api.py
index 1805c39c..868a5441 100644
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -467,3 +467,36 @@ class SourceOmitIncludeTest(CoverageTest):
self.filenames_not_in_summary(lines,
"p1a.py p1c.py p2a.py p2b.py"
)
+
+
+class AnalysisTest(CoverageTest):
+ """Test the numerical analysis of results."""
+ def test_many_missing_branches(self):
+ cov = coverage.coverage(branch=True)
+
+ self.make_file("missing.py", """\
+ def fun1(x):
+ if x == 1:
+ print("one")
+ else:
+ print("not one")
+ print("done") # pragma: nocover
+
+ def fun2(x):
+ print("x")
+
+ fun2(3)
+ """)
+
+ # Import the python file, executing it.
+ cov.start()
+ self.import_local_file("missing") # pragma: recursive coverage
+ cov.stop() # pragma: recursive coverage
+
+ nums = cov._analyze("missing.py").numbers
+ self.assertEqual(nums.n_files, 1)
+ self.assertEqual(nums.n_statements, 7)
+ self.assertEqual(nums.n_excluded, 1)
+ self.assertEqual(nums.n_missing, 3)
+ self.assertEqual(nums.n_branches, 2)
+ self.assertEqual(nums.n_missing_branches, 0)