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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
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
...
@@ -6,14 +6,14 @@ import sys
if
sys
.
version_info
>=
(
3
,
5
,
0
,
'beta'
):
if
sys
.
version_info
>=
(
3
,
5
,
0
,
'beta'
):
# pass Cython implemented AsyncIter() into a Python async-for loop
# pass Cython implemented AsyncIter() into a Python async-for loop
__doc__
=
u"""
__doc__
=
u"""
>>> def test_py35():
>>> def test_py35(
AsyncIterClass
):
... buffer = []
... buffer = []
... async def coro():
... async def coro():
... async for i1, i2 in AsyncIter(1):
... async for i1, i2 in AsyncIter
Class
(1):
... buffer.append(i1 + i2)
... buffer.append(i1 + i2)
... return coro, buffer
... return coro, buffer
>>> testfunc, buffer = test_py35()
>>> testfunc, buffer = test_py35(
AsyncIterOld if sys.version_info < (3, 5, 2) else AsyncIter
)
>>> buffer
>>> buffer
[]
[]
...
@@ -69,7 +69,7 @@ cdef class AsyncIter:
...
@@ -69,7 +69,7 @@ cdef class AsyncIter:
self
.
aiter_calls
=
0
self
.
aiter_calls
=
0
self
.
max_iter_calls
=
max_iter_calls
self
.
max_iter_calls
=
max_iter_calls
async
def
__aiter__
(
self
):
def
__aiter__
(
self
):
self
.
aiter_calls
+=
1
self
.
aiter_calls
+=
1
return
self
return
self
...
@@ -86,6 +86,15 @@ cdef class AsyncIter:
...
@@ -86,6 +86,15 @@ cdef class AsyncIter:
return
self
.
i
,
self
.
i
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
():
def
test_for_1
():
"""
"""
>>> testfunc, buffer = test_for_1()
>>> testfunc, buffer = test_for_1()
...
@@ -154,7 +163,7 @@ def test_for_3():
...
@@ -154,7 +163,7 @@ def test_for_3():
cdef
class
NonAwaitableFromAnext
:
cdef
class
NonAwaitableFromAnext
:
async
def
__aiter__
(
self
):
def
__aiter__
(
self
):
return
self
return
self
def
__anext__
(
self
):
def
__anext__
(
self
):
...
@@ -193,7 +202,7 @@ cdef class Iterable:
...
@@ -193,7 +202,7 @@ cdef class Iterable:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
i
=
0
self
.
i
=
0
async
def
__aiter__
(
self
):
def
__aiter__
(
self
):
return
self
return
self
async
def
__anext__
(
self
):
async
def
__anext__
(
self
):
...
@@ -270,14 +279,22 @@ def test_with_for():
...
@@ -270,14 +279,22 @@ def test_with_for():
print
(
I
[
0
])
print
(
I
[
0
])
cdef
class
AI
:
cdef
class
AI
_old
:
async
def
__aiter__
(
self
):
async
def
__aiter__
(
self
):
1
/
0
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
RAISED
0
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