Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
efd4682b
Commit
efd4682b
authored
May 13, 2015
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 24017: More tests for 'async for' and 'async with'.
parent
9922e900
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
Lib/test/test_coroutines.py
Lib/test/test_coroutines.py
+35
-0
No files found.
Lib/test/test_coroutines.py
View file @
efd4682b
...
...
@@ -623,6 +623,27 @@ class CoroutineTest(unittest.TestCase):
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 @@ class CoroutineTest(unittest.TestCase):
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):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment