summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_monitoring.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_monitoring.py')
-rw-r--r--Lib/test/test_monitoring.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py
index 9d0ad6f..4c74389 100644
--- a/Lib/test/test_monitoring.py
+++ b/Lib/test/test_monitoring.py
@@ -743,6 +743,13 @@ class ExceptionHandledRecorder(ExceptionRecorder):
def __call__(self, code, offset, exc):
self.events.append(("handled", type(exc)))
+class ThrowRecorder(ExceptionRecorder):
+
+ event_type = E.PY_THROW
+
+ def __call__(self, code, offset, exc):
+ self.events.append(("throw", type(exc)))
+
class ExceptionMonitoringTest(CheckEvents):
@@ -888,6 +895,31 @@ class ExceptionMonitoringTest(CheckEvents):
func,
recorders = self.exception_recorders)
+ def test_throw(self):
+
+ def gen():
+ yield 1
+ yield 2
+
+ def func():
+ try:
+ g = gen()
+ next(g)
+ g.throw(IndexError)
+ except IndexError:
+ pass
+
+ self.check_balanced(
+ func,
+ recorders = self.exception_recorders)
+
+ events = self.get_events(
+ func,
+ TEST_TOOL,
+ self.exception_recorders + (ThrowRecorder,)
+ )
+ self.assertEqual(events[0], ("throw", IndexError))
+
class LineRecorder:
event_type = E.LINE