diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_coroutines.py | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py index 036f13f..0e7eb3a 100644 --- a/Lib/test/test_coroutines.py +++ b/Lib/test/test_coroutines.py @@ -2146,99 +2146,6 @@ class CoroAsyncIOCompatTest(unittest.TestCase): self.assertEqual(buffer, [1, 2, 'MyException']) -class SysSetCoroWrapperTest(unittest.TestCase): - - def test_set_wrapper_1(self): - async def foo(): - return 'spam' - - wrapped = None - def wrap(gen): - nonlocal wrapped - wrapped = gen - return gen - - with self.assertWarns(DeprecationWarning): - self.assertIsNone(sys.get_coroutine_wrapper()) - - with self.assertWarns(DeprecationWarning): - sys.set_coroutine_wrapper(wrap) - with self.assertWarns(DeprecationWarning): - self.assertIs(sys.get_coroutine_wrapper(), wrap) - try: - f = foo() - self.assertTrue(wrapped) - - self.assertEqual(run_async(f), ([], 'spam')) - finally: - with self.assertWarns(DeprecationWarning): - sys.set_coroutine_wrapper(None) - f.close() - - with self.assertWarns(DeprecationWarning): - self.assertIsNone(sys.get_coroutine_wrapper()) - - wrapped = None - coro = foo() - self.assertFalse(wrapped) - coro.close() - - def test_set_wrapper_2(self): - with self.assertWarns(DeprecationWarning): - self.assertIsNone(sys.get_coroutine_wrapper()) - with self.assertRaisesRegex(TypeError, "callable expected, got int"): - with self.assertWarns(DeprecationWarning): - sys.set_coroutine_wrapper(1) - with self.assertWarns(DeprecationWarning): - self.assertIsNone(sys.get_coroutine_wrapper()) - - def test_set_wrapper_3(self): - async def foo(): - return 'spam' - - def wrapper(coro): - async def wrap(coro): - return await coro - return wrap(coro) - - with self.assertWarns(DeprecationWarning): - sys.set_coroutine_wrapper(wrapper) - try: - with silence_coro_gc(), self.assertRaisesRegex( - RuntimeError, - r"coroutine wrapper.*\.wrapper at 0x.*attempted to " - r"recursively wrap .* wrap .*"): - - foo() - - finally: - with self.assertWarns(DeprecationWarning): - sys.set_coroutine_wrapper(None) - - def test_set_wrapper_4(self): - @types.coroutine - def foo(): - return 'spam' - - wrapped = None - def wrap(gen): - nonlocal wrapped - wrapped = gen - return gen - - with self.assertWarns(DeprecationWarning): - sys.set_coroutine_wrapper(wrap) - try: - foo() - self.assertIs( - wrapped, None, - "generator-based coroutine was wrapped via " - "sys.set_coroutine_wrapper") - finally: - with self.assertWarns(DeprecationWarning): - sys.set_coroutine_wrapper(None) - - class OriginTrackingTest(unittest.TestCase): def here(self): info = inspect.getframeinfo(inspect.currentframe().f_back) |