summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-12-23 15:41:36 -0500
committerNed Batchelder <ned@nedbatchelder.com>2019-12-23 18:01:49 -0500
commit42a651c6e23b4156c5bc37208d97d0788e09edf7 (patch)
treeed9291ef67071d7a22969f15a55df0584e3ac61e /tests
parent7c78d66bf029796961ed528b1d00c561aaa8ceb7 (diff)
downloadpython-coveragepy-git-42a651c6e23b4156c5bc37208d97d0788e09edf7.tar.gz
A way to artificially crash coverage, for testing.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_api.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_api.py b/tests/test_api.py
index 30a90c3c..369324f7 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -676,6 +676,21 @@ class ApiTest(CoverageTest):
with self.assertRaisesRegex(CoverageException, msg):
cov.switch_context("test3")
+ def test_config_crash(self):
+ # The internal '[run] _crash' setting can be used to artificially raise
+ # exceptions from inside Coverage.
+ cov = coverage.Coverage()
+ cov.set_option("run:_crash", "test_config_crash")
+ with self.assertRaisesRegex(Exception, "Crashing because called by test_config_crash"):
+ cov.start()
+
+ def test_config_crash_no_crash(self):
+ # '[run] _crash' really checks the call stack.
+ cov = coverage.Coverage()
+ cov.set_option("run:_crash", "not_my_caller")
+ cov.start()
+ cov.stop()
+
class CurrentInstanceTest(CoverageTest):
"""Tests of Coverage.current()."""