Author: Armin Rigo <ar...@tunes.org>
Branch: py3.5-corowrapper
Changeset: r87196:3821014886f7
Date: 2016-09-17 22:25 +0200
http://bitbucket.org/pypy/pypy/changeset/3821014886f7/

Log:    Direct test for 'await'

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
@@ -25,7 +25,7 @@
             return sum
         cr = f(X())
         try:
-            next(cr.__await__())
+            cr.send(None)
         except StopIteration as e:
             assert e.value == 42 * 3
         else:
@@ -79,10 +79,28 @@
                 return 42
         c = f(X())
         try:
-            next(c.__await__())
+            c.send(None)
         except StopIteration as e:
             assert e.value == 42
         else:
             assert False, "should have raised"
         assert seen == ['aenter', 'aexit']
         """
+
+    def test_await(self): """
+        class X:
+            def __await__(self):
+                i1 = yield 40
+                assert i1 == 82
+                i2 = yield 41
+                assert i2 == 93
+        async def f():
+            await X()
+            await X()
+        c = f()
+        assert c.send(None) == 40
+        assert c.send(82) == 41
+        assert c.send(93) == 40
+        assert c.send(82) == 41
+        raises(StopIteration, c.send, 93)
+        """
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to