[pypy-commit] pypy py3.5-corowrapper: A direct test for "async for" (I have still no idea how we're supposed
arigo
pypy.commits at gmail.com
Sat Sep 17 13:04:45 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5-corowrapper
Changeset: r87183:a8123d99589e
Date: 2016-09-17 19:04 +0200
http://bitbucket.org/pypy/pypy/changeset/a8123d99589e/
Log: A direct test for "async for" (I have still no idea how we're
supposed to call a coroutine)
diff --git a/pypy/interpreter/test/test_coroutine.py b/pypy/interpreter/test/test_coroutine.py
--- a/pypy/interpreter/test/test_coroutine.py
+++ b/pypy/interpreter/test/test_coroutine.py
@@ -8,3 +8,26 @@
raises(TypeError, iter, f(5))
raises(TypeError, next, f(5))
"""
+
+ def test_async_for(self): """
+ class X:
+ def __aiter__(self):
+ return MyAIter()
+ class MyAIter:
+ async def __anext__(self):
+ return 42
+ async def f(x):
+ sum = 0
+ async for a in x:
+ sum += a
+ if sum > 100:
+ break
+ return sum
+ cr = f(X())
+ try:
+ next(cr.__await__())
+ except StopIteration as e:
+ assert e.value == 42 * 3
+ else:
+ assert False, "should have raised"
+ """
More information about the pypy-commit
mailing list