bpo-32591: silence deprecation warnings in test_coroutine (GH-5412)
This commit is contained in:
parent
1e5b25b8c0
commit
95e214713a
@ -1981,6 +1981,7 @@ class SysSetCoroWrapperTest(unittest.TestCase):
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
sys.set_coroutine_wrapper(wrap)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertIs(sys.get_coroutine_wrapper(), wrap)
|
||||
try:
|
||||
f = foo()
|
||||
@ -1988,8 +1989,10 @@ class SysSetCoroWrapperTest(unittest.TestCase):
|
||||
|
||||
self.assertEqual(run_async(f), ([], 'spam'))
|
||||
finally:
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
sys.set_coroutine_wrapper(None)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertIsNone(sys.get_coroutine_wrapper())
|
||||
|
||||
wrapped = None
|
||||
@ -1998,9 +2001,12 @@ class SysSetCoroWrapperTest(unittest.TestCase):
|
||||
self.assertFalse(wrapped)
|
||||
|
||||
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):
|
||||
@ -2012,6 +2018,7 @@ class SysSetCoroWrapperTest(unittest.TestCase):
|
||||
return await coro
|
||||
return wrap(coro)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
sys.set_coroutine_wrapper(wrapper)
|
||||
try:
|
||||
with silence_coro_gc(), self.assertRaisesRegex(
|
||||
@ -2021,6 +2028,7 @@ class SysSetCoroWrapperTest(unittest.TestCase):
|
||||
|
||||
foo()
|
||||
finally:
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
sys.set_coroutine_wrapper(None)
|
||||
|
||||
def test_set_wrapper_4(self):
|
||||
@ -2034,6 +2042,7 @@ class SysSetCoroWrapperTest(unittest.TestCase):
|
||||
wrapped = gen
|
||||
return gen
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
sys.set_coroutine_wrapper(wrap)
|
||||
try:
|
||||
foo()
|
||||
@ -2042,6 +2051,7 @@ class SysSetCoroWrapperTest(unittest.TestCase):
|
||||
"generator-based coroutine was wrapped via "
|
||||
"sys.set_coroutine_wrapper")
|
||||
finally:
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
sys.set_coroutine_wrapper(None)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user