summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel J. Smith <njs@pobox.com>2018-01-29 07:34:26 (GMT)
committerGitHub <noreply@github.com>2018-01-29 07:34:26 (GMT)
commit95e214713a7da4e5cbfb73f35b2119f76074fc3f (patch)
tree230c43c217077d71d1233368855c61be985c4dd2
parent1e5b25b8c0c45ccfd58da2cb82fdf231c6823fef (diff)
downloadcpython-95e214713a7da4e5cbfb73f35b2119f76074fc3f.zip
cpython-95e214713a7da4e5cbfb73f35b2119f76074fc3f.tar.gz
cpython-95e214713a7da4e5cbfb73f35b2119f76074fc3f.tar.bz2
bpo-32591: silence deprecation warnings in test_coroutine (GH-5412)
-rw-r--r--Lib/test/test_coroutines.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
index a97535a..19a3444 100644
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -1981,16 +1981,19 @@ class SysSetCoroWrapperTest(unittest.TestCase):
with self.assertWarns(DeprecationWarning):
sys.set_coroutine_wrapper(wrap)
- self.assertIs(sys.get_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:
- sys.set_coroutine_wrapper(None)
+ with self.assertWarns(DeprecationWarning):
+ sys.set_coroutine_wrapper(None)
- self.assertIsNone(sys.get_coroutine_wrapper())
+ with self.assertWarns(DeprecationWarning):
+ self.assertIsNone(sys.get_coroutine_wrapper())
wrapped = None
with silence_coro_gc():
@@ -1998,10 +2001,13 @@ class SysSetCoroWrapperTest(unittest.TestCase):
self.assertFalse(wrapped)
def test_set_wrapper_2(self):
- self.assertIsNone(sys.get_coroutine_wrapper())
+ with self.assertWarns(DeprecationWarning):
+ self.assertIsNone(sys.get_coroutine_wrapper())
with self.assertRaisesRegex(TypeError, "callable expected, got int"):
- sys.set_coroutine_wrapper(1)
- self.assertIsNone(sys.get_coroutine_wrapper())
+ 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():
@@ -2012,7 +2018,8 @@ class SysSetCoroWrapperTest(unittest.TestCase):
return await coro
return wrap(coro)
- sys.set_coroutine_wrapper(wrapper)
+ with self.assertWarns(DeprecationWarning):
+ sys.set_coroutine_wrapper(wrapper)
try:
with silence_coro_gc(), self.assertRaisesRegex(
RuntimeError,
@@ -2021,7 +2028,8 @@ class SysSetCoroWrapperTest(unittest.TestCase):
foo()
finally:
- sys.set_coroutine_wrapper(None)
+ with self.assertWarns(DeprecationWarning):
+ sys.set_coroutine_wrapper(None)
def test_set_wrapper_4(self):
@types.coroutine
@@ -2034,7 +2042,8 @@ class SysSetCoroWrapperTest(unittest.TestCase):
wrapped = gen
return gen
- sys.set_coroutine_wrapper(wrap)
+ with self.assertWarns(DeprecationWarning):
+ sys.set_coroutine_wrapper(wrap)
try:
foo()
self.assertIs(
@@ -2042,7 +2051,8 @@ class SysSetCoroWrapperTest(unittest.TestCase):
"generator-based coroutine was wrapped via "
"sys.set_coroutine_wrapper")
finally:
- sys.set_coroutine_wrapper(None)
+ with self.assertWarns(DeprecationWarning):
+ sys.set_coroutine_wrapper(None)
class OriginTrackingTest(unittest.TestCase):