[Python-checkins] cpython: Issue 24017: More tests for 'async for' and 'async with'.
yury.selivanov
python-checkins at python.org
Wed May 13 22:49:52 CEST 2015
https://hg.python.org/cpython/rev/0d80d46adfdb
changeset: 96037:0d80d46adfdb
user: Yury Selivanov <yselivanov at sprymix.com>
date: Wed May 13 16:49:35 2015 -0400
summary:
Issue 24017: More tests for 'async for' and 'async with'.
files:
Lib/test/test_coroutines.py | 35 +++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -623,6 +623,27 @@
run_async(foo())
+ def test_with_13(self):
+ CNT = 0
+
+ class CM:
+ async def __aenter__(self):
+ 1/0
+
+ async def __aexit__(self, *e):
+ return True
+
+ async def foo():
+ nonlocal CNT
+ CNT += 1
+ async with CM():
+ CNT += 1000
+ CNT += 10000
+
+ with self.assertRaises(ZeroDivisionError):
+ run_async(foo())
+ self.assertEqual(CNT, 1)
+
def test_for_1(self):
aiter_calls = 0
@@ -859,6 +880,20 @@
run_async(main())
self.assertEqual(I, 20555255)
+ def test_for_7(self):
+ CNT = 0
+ class AI:
+ async def __aiter__(self):
+ 1/0
+ async def foo():
+ nonlocal CNT
+ async for i in AI():
+ CNT += 1
+ CNT += 10
+ with self.assertRaises(ZeroDivisionError):
+ run_async(foo())
+ self.assertEqual(CNT, 0)
+
class CoroAsyncIOCompatTest(unittest.TestCase):
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list