cpython: 0d80d46adfdb (original) (raw)
Mercurial > cpython
changeset 96037:0d80d46adfdb
Issue 24017: More tests for 'async for' and 'async with'.
Yury Selivanov yselivanov@sprymix.com | |
---|---|
date | Wed, 13 May 2015 16:49:35 -0400 |
parents | 94eddf8ec0e5 |
children | ee31277386cb |
files | Lib/test/test_coroutines.py |
diffstat | 1 files changed, 35 insertions(+), 0 deletions(-)[+] [-] Lib/test/test_coroutines.py 35 |
line wrap: on
line diff
--- a/Lib/test/test_coroutines.py +++ b/Lib/test/test_coroutines.py @@ -623,6 +623,27 @@ class CoroutineTest(unittest.TestCase): run_async(foo())
class CM:[](#l1.10)
async def __aenter__(self):[](#l1.11)
1/0[](#l1.12)
async def __aexit__(self, *e):[](#l1.14)
return True[](#l1.15)
async def foo():[](#l1.17)
nonlocal CNT[](#l1.18)
CNT += 1[](#l1.19)
async with CM():[](#l1.20)
CNT += 1000[](#l1.21)
CNT += 10000[](#l1.22)
with self.assertRaises(ZeroDivisionError):[](#l1.24)
run_async(foo())[](#l1.25)
self.assertEqual(CNT, 1)[](#l1.26)
+ def test_for_1(self): aiter_calls = 0 @@ -859,6 +880,20 @@ class CoroutineTest(unittest.TestCase): run_async(main()) self.assertEqual(I, 20555255)
- def test_for_7(self):
CNT = 0[](#l1.36)
class AI:[](#l1.37)
async def __aiter__(self):[](#l1.38)
1/0[](#l1.39)
async def foo():[](#l1.40)
nonlocal CNT[](#l1.41)
async for i in AI():[](#l1.42)
CNT += 1[](#l1.43)
CNT += 10[](#l1.44)
with self.assertRaises(ZeroDivisionError):[](#l1.45)
run_async(foo())[](#l1.46)
self.assertEqual(CNT, 0)[](#l1.47)