diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2019-12-27 17:35:51 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-12-27 17:52:41 -0500 |
commit | 16ef35f9be4f7b225750fac576e0f6245a100752 (patch) | |
tree | da5b7114396ed4a74b751130f3bfd12817bd24e8 /tests/test_api.py | |
parent | cc989e2547fa796c84ba55b07dcf55d509c077f1 (diff) | |
download | python-coveragepy-git-16ef35f9be4f7b225750fac576e0f6245a100752.tar.gz |
Warn if two things change the dynamic context. #901
Diffstat (limited to 'tests/test_api.py')
-rw-r--r-- | tests/test_api.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_api.py b/tests/test_api.py index 63a0c7b1..0a6b71b9 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -672,6 +672,19 @@ class ApiTest(CoverageTest): data.set_query_context("mysuite|multiply_zero") self.assertEqual([2, 5], sorted(data.lines(suite_filename))) + def test_dynamic_context_conflict(self): + cov = coverage.Coverage(source=["."]) + cov.set_option("run:dynamic_context", "test_function") + cov.start() + # Switch twice, but only get one warning. + cov.switch_context("test1") # pragma: nested + cov.switch_context("test2") # pragma: nested + self.assertEqual( # pragma: nested + self.stderr(), + "Coverage.py warning: Conflicting dynamic contexts (dynamic-conflict)\n" + ) + cov.stop() # pragma: nested + def test_switch_context_unstarted(self): # Coverage must be started to switch context msg = "Cannot switch context, coverage is not started" |