[Python-checkins] cpython (3.5): Issue #24400: Add one more unittest for CoroutineType.__await__
yury.selivanov
python-checkins at python.org
Wed Jul 1 18:34:44 CEST 2015
https://hg.python.org/cpython/rev/a9d38701536d
changeset: 96744:a9d38701536d
branch: 3.5
parent: 96742:5d1e16be1af6
user: Yury Selivanov <yselivanov at sprymix.com>
date: Wed Jul 01 12:29:55 2015 -0400
summary:
Issue #24400: Add one more unittest for CoroutineType.__await__
files:
Lib/test/test_coroutines.py | 34 +++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -519,6 +519,40 @@
run_async(foo())
+ def test_await_14(self):
+ class Wrapper:
+ # Forces the interpreter to use CoroutineType.__await__
+ def __init__(self, coro):
+ assert coro.__class__ is types.CoroutineType
+ self.coro = coro
+ def __await__(self):
+ return self.coro.__await__()
+
+ class FutureLike:
+ def __await__(self):
+ return (yield)
+
+ class Marker(Exception):
+ pass
+
+ async def coro1():
+ try:
+ return await FutureLike()
+ except ZeroDivisionError:
+ raise Marker
+ async def coro2():
+ return await Wrapper(coro1())
+
+ c = coro2()
+ c.send(None)
+ with self.assertRaisesRegex(StopIteration, 'spam'):
+ c.send('spam')
+
+ c = coro2()
+ c.send(None)
+ with self.assertRaises(Marker):
+ c.throw(ZeroDivisionError)
+
def test_with_1(self):
class Manager:
def __init__(self, name):
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list