diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_api.py | 33 | ||||
-rw-r--r-- | test/test_summary.py | 5 |
2 files changed, 36 insertions, 2 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) diff --git a/test/test_summary.py b/test/test_summary.py index 306ce883..499a7159 100644 --- a/test/test_summary.py +++ b/test/test_summary.py @@ -138,8 +138,9 @@ class SummaryTest2(CoverageTest): def setUp(self): super(SummaryTest2, self).setUp() # Parent class saves and restores sys.path, we can just modify it. - sys.path.append(self.nice_file(os.path.dirname(__file__), 'modules')) - sys.path.append(self.nice_file(os.path.dirname(__file__), 'moremodules')) + this_dir = os.path.dirname(__file__) + sys.path.append(self.nice_file(this_dir, 'modules')) + sys.path.append(self.nice_file(this_dir, 'moremodules')) def test_empty_files(self): # Shows that empty files like __init__.py are listed as having zero |