Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
cd84429f
Commit
cd84429f
authored
Jun 11, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update async iter tests to match Py3.5.2+ interface
parent
64c0c794
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
9 deletions
+26
-9
tests/run/async_iter_pep492.pyx
tests/run/async_iter_pep492.pyx
+26
-9
No files found.
tests/run/async_iter_pep492.pyx
View file @
cd84429f
...
...
@@ -6,14 +6,14 @@ import sys
if
sys
.
version_info
>=
(
3
,
5
,
0
,
'beta'
):
# pass Cython implemented AsyncIter() into a Python async-for loop
__doc__
=
u"""
>>> def test_py35():
>>> def test_py35(
AsyncIterClass
):
... buffer = []
... async def coro():
... async for i1, i2 in AsyncIter(1):
... async for i1, i2 in AsyncIter
Class
(1):
... buffer.append(i1 + i2)
... return coro, buffer
>>> testfunc, buffer = test_py35()
>>> testfunc, buffer = test_py35(
AsyncIterOld if sys.version_info < (3, 5, 2) else AsyncIter
)
>>> buffer
[]
...
...
@@ -69,7 +69,7 @@ cdef class AsyncIter:
self
.
aiter_calls
=
0
self
.
max_iter_calls
=
max_iter_calls
async
def
__aiter__
(
self
):
def
__aiter__
(
self
):
self
.
aiter_calls
+=
1
return
self
...
...
@@ -86,6 +86,15 @@ cdef class AsyncIter:
return
self
.
i
,
self
.
i
cdef
class
AsyncIterOld
(
AsyncIter
):
"""
Same as AsyncIter, but with the old async-def interface for __aiter__().
"""
async
def
__aiter__
(
self
):
self
.
aiter_calls
+=
1
return
self
def
test_for_1
():
"""
>>> testfunc, buffer = test_for_1()
...
...
@@ -154,7 +163,7 @@ def test_for_3():
cdef
class
NonAwaitableFromAnext
:
async
def
__aiter__
(
self
):
def
__aiter__
(
self
):
return
self
def
__anext__
(
self
):
...
...
@@ -193,7 +202,7 @@ cdef class Iterable:
def
__init__
(
self
):
self
.
i
=
0
async
def
__aiter__
(
self
):
def
__aiter__
(
self
):
return
self
async
def
__anext__
(
self
):
...
...
@@ -270,14 +279,22 @@ def test_with_for():
print
(
I
[
0
])
cdef
class
AI
:
cdef
class
AI
_old
:
async
def
__aiter__
(
self
):
1
/
0
def
test_aiter_raises
():
cdef
class
AI_new
:
def
__aiter__
(
self
):
1
/
0
def
test_aiter_raises
(
AI
):
"""
>>> test_aiter_raises()
>>> test_aiter_raises(AI_old)
RAISED
0
>>> test_aiter_raises(AI_new)
RAISED
0
"""
...
...
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