summaryrefslogtreecommitdiff
path: root/test/test_api.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2012-12-28 06:02:23 -0500
committerNed Batchelder <ned@nedbatchelder.com>2012-12-28 06:02:23 -0500
commit3ef81fc93546470e2e1158bef547a1194e5cb67f (patch)
treea097429229ce3d08297ffc04ccaf9ee705ec1b6b /test/test_api.py
parent60a5f3e1c4d8b323dd5e7b48d06a6de50f1cf1fa (diff)
downloadpython-coveragepy-git-3ef81fc93546470e2e1158bef547a1194e5cb67f.tar.gz
Preventing double harvesting was keeping the nose plugin from working. Not sure what it was meant to solve in the first place. Fixes #224. Maybe allows double warnings now?
Diffstat (limited to 'test/test_api.py')
-rw-r--r--test/test_api.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/test_api.py b/test/test_api.py
index 4c4f7650..e83d8b75 100644
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -487,3 +487,42 @@ class AnalysisTest(CoverageTest):
self.assertEqual(nums.n_branches, 2)
self.assertEqual(nums.n_partial_branches, 0)
self.assertEqual(nums.n_missing_branches, 2)
+
+
+class PluginTest(CoverageTest):
+ """Test that the API works properly the way the plugins call it.
+
+ We don't actually use the plugins, but these tests call the API the same
+ way they do.
+
+ """
+ def pretend_to_be_nose_with_cover(self, erase):
+ """This is what the nose --with-cover plugin does."""
+ cov = coverage.coverage()
+
+ self.make_file("no_biggie.py", """\
+ a = 1
+ b = 2
+ if b == 1:
+ c = 4
+ """)
+
+ if erase:
+ cov.combine()
+ cov.erase()
+ cov.load()
+ self.start_import_stop(cov, "no_biggie")
+ cov.combine()
+ cov.save()
+ cov.report(["no_biggie.py"])
+ self.assertEqual(self.stdout(), textwrap.dedent("""\
+ Name Stmts Miss Cover Missing
+ -----------------------------------------
+ no_biggie 4 1 75% 4
+ """))
+
+ def test_nose_plugin(self):
+ self.pretend_to_be_nose_with_cover(erase=False)
+
+ def test_nose_plugin_with_erase(self):
+ self.pretend_to_be_nose_with_cover(erase=True)