diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2011-08-02 22:25:30 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2011-08-02 22:25:30 -0400 |
commit | 37850e04b59675a7292f8b6b810c932be0b4939d (patch) | |
tree | e0482d29ec9862cda5a0258031c7c0c58bee6943 | |
parent | 3436d05a5f5b8c081946b1764d1411aa3bb83806 (diff) | |
download | python-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.
-rw-r--r-- | CHANGES.txt | 3 | ||||
-rw-r--r-- | coverage/results.py | 4 | ||||
-rw-r--r-- | test/test_api.py | 33 |
3 files changed, 39 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 03c310d2..e41bfc11 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,9 @@ Change history for Coverage.py Version 3.5.1 ------------- +- The number of partial branches reported on the HTML summary page was + different than the number reported on the individual file pages. This is + now fixed. Version 3.5 --- 29 June 2011 diff --git a/coverage/results.py b/coverage/results.py index adfb8f42..d7e2a9d1 100644 --- a/coverage/results.py +++ b/coverage/results.py @@ -41,7 +41,9 @@ class Analysis(object): ) n_branches = self.total_branches() mba = self.missing_branch_arcs() - n_missing_branches = sum([len(v) for v in mba.values()]) + n_missing_branches = sum( + [len(v) for k,v in mba.items() if k not in self.missing] + ) else: n_branches = n_missing_branches = 0 self.no_branch = set() 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) |