Author: Armin Rigo <ar...@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"
+        """
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to