From 0025350294959594e7f57aef4fc9579c77a0ed1c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 3 Jun 2019 03:51:43 +0200 Subject: 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(). --- Lib/test/test_yield_from.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Lib/test/test_yield_from.py') diff --git a/Lib/test/test_yield_from.py b/Lib/test/test_yield_from.py index ce21c3df81..4735ef4bee 100644 --- a/Lib/test/test_yield_from.py +++ b/Lib/test/test_yield_from.py @@ -11,6 +11,7 @@ import unittest import inspect from test.support import captured_stderr, disable_gc, gc_collect +from test import support class TestPEP380Operation(unittest.TestCase): """ @@ -562,11 +563,12 @@ class TestPEP380Operation(unittest.TestCase): self.assertEqual(next(gi), 1) gi.throw(AttributeError) - with captured_stderr() as output: + with support.catch_unraisable_exception() as cm: gi = g() self.assertEqual(next(gi), 1) gi.close() - self.assertIn('ZeroDivisionError', output.getvalue()) + + self.assertEqual(ZeroDivisionError, cm.unraisable.exc_type) def test_exception_in_initial_next_call(self): """ -- cgit v1.2.1