Author: Mariano Anaya <[email protected]>
Branch: py3.6
Changeset: r91897:6f9eb0f25f77
Date: 2017-07-16 14:49 +0200
http://bitbucket.org/pypy/pypy/changeset/6f9eb0f25f77/
Log: Add test for async generators with asend and throw, and vice-versa
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
@@ -383,3 +383,33 @@
e = raises(StopIteration, gs.send, "bar")
assert e.value.args == ()
"""
+
+ def test_async_yield_asend_notnone_throw(self): """
+ async def f():
+ yield 123
+
+ raises(ValueError, f().asend(42).throw, ValueError)
+ """
+
+ def test_async_yield_asend_none_throw(self): """
+ async def f():
+ yield 123
+
+ raises(ValueError, f().asend(None).throw, ValueError)
+ """
+
+ def test_async_yield_athrow_send_none(self): """
+ async def ag():
+ yield 42
+
+ raises(ValueError, ag().athrow(ValueError).send, None)
+ """
+
+ def test_async_yield_athrow_send_notnone(self): """
+ async def ag():
+ yield 42
+
+ ex = raises(RuntimeError, ag().athrow(ValueError).send, 42)
+ expected = ("can't send non-None value to a just-started coroutine", )
+ assert ex.value.args == expected
+ """
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit