summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-07-01 16:30:26 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-07-01 16:30:26 (GMT)
commit9dbd4790a3f74105b4bf9cacc1ce5d99f55b2968 (patch)
treed01bfe3688e23ee62f128c23a7aed0816b881e82 /Lib
parent89ca395c0c0609e6a25d599fd14eab6cbf92f552 (diff)
parentf27015255f899d3c36fb3c096fe1faa7b123d05b (diff)
downloadcpython-9dbd4790a3f74105b4bf9cacc1ce5d99f55b2968.zip
cpython-9dbd4790a3f74105b4bf9cacc1ce5d99f55b2968.tar.gz
cpython-9dbd4790a3f74105b4bf9cacc1ce5d99f55b2968.tar.bz2
Merge 3.5
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_coroutines.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
index a84e27a..3413a12 100644
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -519,6 +519,40 @@ class CoroutineTest(unittest.TestCase):
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):