summaryrefslogtreecommitdiff
path: root/tests/test_context.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2018-09-15 08:07:26 -0400
committerNed Batchelder <ned@nedbatchelder.com>2018-09-21 17:56:49 -0400
commitd2f77ab2ffc308e616af0207546ee1bef1cb8c75 (patch)
tree1cfa74a6998eb7bbc08ce28594b5f80dff457d65 /tests/test_context.py
parent2f1b8cfcfe184a8fd6f3f2f789530bddb233dda8 (diff)
downloadpython-coveragepy-git-d2f77ab2ffc308e616af0207546ee1bef1cb8c75.tar.gz
measured_contexts() and two simple tests of the global context
Diffstat (limited to 'tests/test_context.py')
-rw-r--r--tests/test_context.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_context.py b/tests/test_context.py
new file mode 100644
index 00000000..ec1e4885
--- /dev/null
+++ b/tests/test_context.py
@@ -0,0 +1,30 @@
+# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
+# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
+
+"""Tests for context support."""
+
+import coverage
+
+from tests.coveragetest import CoverageTest
+
+
+class GlobalContextTest(CoverageTest):
+ """Tests of the global context."""
+
+ def setUp(self):
+ super(GlobalContextTest, self).setUp()
+ self.skip_unless_data_storage_is("sql")
+
+ def test_no_context(self):
+ self.make_file("main.py", "a = 1")
+ cov = coverage.Coverage()
+ self.start_import_stop(cov, "main")
+ data = cov.get_data()
+ self.assertCountEqual(data.measured_contexts(), [""])
+
+ def test_global_context(self):
+ self.make_file("main.py", "a = 1")
+ cov = coverage.Coverage(context="gooey")
+ self.start_import_stop(cov, "main")
+ data = cov.get_data()
+ self.assertCountEqual(data.measured_contexts(), ["gooey"])