summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_generators.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_generators.py')
-rw-r--r--Lib/test/test_generators.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 7f1472f..a34e4ec 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -2051,15 +2051,17 @@ RuntimeError: generator ignored GeneratorExit
Our ill-behaved code should be invoked during GC:
->>> import sys, io
->>> old, sys.stderr = sys.stderr, io.StringIO()
->>> g = f()
->>> next(g)
->>> del g
->>> "RuntimeError: generator ignored GeneratorExit" in sys.stderr.getvalue()
+>>> with support.catch_unraisable_exception() as cm:
+... g = f()
+... next(g)
+... del g
+...
+... cm.unraisable.exc_type == RuntimeError
+... "generator ignored GeneratorExit" in str(cm.unraisable.exc_value)
+... cm.unraisable.exc_traceback is not None
+True
+True
True
->>> sys.stderr = old
-
And errors thrown during closing should propagate: