bpo-32591: silence deprecation warnings in test_coroutine (GH-5412)

This commit is contained in:
Nathaniel J. Smith 2018-01-28 23:34:26 -08:00 committed by GitHub
parent 1e5b25b8c0
commit 95e214713a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)