mirror of
https://github.com/python/cpython.git
synced 2025-09-02 23:18:25 +00:00
bpo-37069: tests use catch_unraisable_exception() (GH-13762)
Modify test_coroutines, test_cprofile, test_generators, test_raise, test_ssl and test_yield_from to use support.catch_unraisable_exception() rather than support.captured_stderr(). test_thread: remove test_save_exception_state_on_error() which is now updated. test_unraisable_exception() checks that sys.unraisablehook() is called to handle _thread.start_new_thread() exception. test_cprofile now rely on unittest for test discovery: replace support.run_unittest() with unittest.main().
This commit is contained in:
parent
13136e83a6
commit
0025350294
8 changed files with 60 additions and 69 deletions
|
@ -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:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue