From 3880f263d2994fb1eba25835dddccb0cf696fdf0 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Tue, 28 May 2019 00:10:59 -0700 Subject: bpo-36933: Remove sys.set_coroutine_wrapper (marked for removal in 3.8) (GH-13577) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It has been documented as deprecated and to be removed in 3.8; From a comment on another thread – which I can't find ; leave get_coro_wrapper() for now, but always return `None`. https://bugs.python.org/issue36933 --- Lib/test/test_coroutines.py | 93 --------------------------------------------- 1 file changed, 93 deletions(-) (limited to 'Lib/test/test_coroutines.py') diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py index 036f13fa50e..0e7eb3a1af4 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) -- cgit v1.2.3