summaryrefslogtreecommitdiff
path: root/tests/test_plugins.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-01-24 11:31:02 -0500
committerNed Batchelder <ned@nedbatchelder.com>2015-01-24 11:31:02 -0500
commitd2c87fd4a23ef71f13d6e90aca98585ac515d551 (patch)
tree54f217746b6d1218beee1bd7c219c3a97a993d37 /tests/test_plugins.py
parent4ddf53a6d962a001782a0838b1b8748041125be4 (diff)
downloadpython-coveragepy-git-d2c87fd4a23ef71f13d6e90aca98585ac515d551.tar.gz
Plugins can provide sysinfo
Diffstat (limited to 'tests/test_plugins.py')
-rw-r--r--tests/test_plugins.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_plugins.py b/tests/test_plugins.py
index 718bf2ca..5485005b 100644
--- a/tests/test_plugins.py
+++ b/tests/test_plugins.py
@@ -4,6 +4,7 @@ import os.path
import coverage
from coverage import env
+from coverage.backward import StringIO
from coverage.control import Plugins
import coverage.plugin
@@ -136,6 +137,48 @@ class PluginTest(CoverageTest):
cov.start()
cov.stop()
+ def test_plugin_sysinfo(self):
+ self.make_file("plugin_sysinfo.py", """\
+ import coverage
+
+ class Plugin(coverage.CoveragePlugin):
+ def sysinfo(self):
+ return [("hello", "world")]
+ """)
+ debug_out = StringIO()
+ cov = coverage.Coverage(debug=["sys"])
+ cov._debug_file = debug_out
+ cov.config["run:plugins"] = ["plugin_sysinfo"]
+ cov.load()
+
+ out_lines = debug_out.getvalue().splitlines()
+ expected_end = [
+ "-- sys: plugin_sysinfo ---------------------------------------",
+ " hello: world",
+ "-- end -------------------------------------------------------",
+ ]
+ self.assertEqual(expected_end, out_lines[-len(expected_end):])
+
+ def test_plugin_with_no_sysinfo(self):
+ self.make_file("plugin_no_sysinfo.py", """\
+ import coverage
+
+ class Plugin(coverage.CoveragePlugin):
+ pass
+ """)
+ debug_out = StringIO()
+ cov = coverage.Coverage(debug=["sys"])
+ cov._debug_file = debug_out
+ cov.config["run:plugins"] = ["plugin_no_sysinfo"]
+ cov.load()
+
+ out_lines = debug_out.getvalue().splitlines()
+ expected_end = [
+ "-- sys: plugin_no_sysinfo ------------------------------------",
+ "-- end -------------------------------------------------------",
+ ]
+ self.assertEqual(expected_end, out_lines[-len(expected_end):])
+
if not env.C_TRACER:
class FileTracerTest(CoverageTest):