diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2018-09-15 08:07:26 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2018-09-21 17:56:49 -0400 |
commit | d2f77ab2ffc308e616af0207546ee1bef1cb8c75 (patch) | |
tree | 1cfa74a6998eb7bbc08ce28594b5f80dff457d65 /tests/test_context.py | |
parent | 2f1b8cfcfe184a8fd6f3f2f789530bddb233dda8 (diff) | |
download | python-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.py | 30 |
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"]) |