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
00c0b092
Commit
00c0b092
authored
Jul 29, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unittest fixes and work-arounds for older Python versions
parent
e9726181
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
tests/run/test_asyncgen.py
tests/run/test_asyncgen.py
+23
-11
No files found.
tests/run/test_asyncgen.py
View file @
00c0b092
...
...
@@ -81,6 +81,7 @@ except ImportError:
def
__next__
(
self
):
return
next
(
self
.
__wrapped
)
next
=
__next__
def
__iter__
(
self
):
if
self
.
__isgen
:
...
...
@@ -221,12 +222,23 @@ class AsyncGenSyntaxTest(unittest.TestCase):
class
AsyncGenTest
(
unittest
.
TestCase
):
if
sys
.
version_info
<
(
3
,
3
):
@
contextlib
.
contextmanager
def
assertRaisesRegex
(
self
,
exc_type
,
regex
):
# the error messages usually don't match, so we just ignore them
try
:
yield
except
exc_type
:
self
.
assertTrue
(
True
)
else
:
self
.
assertTrue
(
False
)
def
compare_generators
(
self
,
sync_gen
,
async_gen
):
def
sync_iterate
(
g
):
res
=
[]
while
True
:
try
:
res
.
append
(
g
.
__next__
(
))
res
.
append
(
next
(
g
))
except
StopIteration
:
res
.
append
(
'STOP'
)
break
...
...
@@ -238,7 +250,7 @@ class AsyncGenTest(unittest.TestCase):
res
=
[]
while
True
:
try
:
g
.
__anext__
().
__next__
(
)
next
(
g
.
__anext__
()
)
except
StopAsyncIteration
:
res
.
append
(
'STOP'
)
break
...
...
@@ -277,19 +289,19 @@ class AsyncGenTest(unittest.TestCase):
g
=
gen
()
ai
=
g
.
__aiter__
()
self
.
assertEqual
(
ai
.
__anext__
().
__next__
(
),
(
'result'
,))
self
.
assertEqual
(
next
(
ai
.
__anext__
()
),
(
'result'
,))
try
:
ai
.
__anext__
().
__next__
(
)
next
(
ai
.
__anext__
()
)
except
StopIteration
as
ex
:
self
.
assertEqual
(
ex
.
args
[
0
],
123
)
else
:
self
.
fail
(
'StopIteration was not raised'
)
self
.
assertEqual
(
ai
.
__anext__
().
__next__
(
),
(
'result'
,))
self
.
assertEqual
(
next
(
ai
.
__anext__
()
),
(
'result'
,))
try
:
ai
.
__anext__
().
__next__
(
)
next
(
ai
.
__anext__
()
)
except
StopAsyncIteration
as
ex
:
self
.
assertFalse
(
ex
.
args
)
else
:
...
...
@@ -313,17 +325,17 @@ class AsyncGenTest(unittest.TestCase):
g
=
gen
()
ai
=
g
.
__aiter__
()
self
.
assertEqual
(
ai
.
__anext__
().
__next__
(
),
(
'result'
,))
self
.
assertEqual
(
next
(
ai
.
__anext__
()
),
(
'result'
,))
try
:
ai
.
__anext__
().
__next__
(
)
next
(
ai
.
__anext__
()
)
except
StopIteration
as
ex
:
self
.
assertEqual
(
ex
.
args
[
0
],
123
)
else
:
self
.
fail
(
'StopIteration was not raised'
)
with
self
.
assertRaises
(
ZeroDivisionError
):
ai
.
__anext__
().
__next__
(
)
next
(
ai
.
__anext__
()
)
def
test_async_gen_exception_05
(
self
):
async
def
gen
():
...
...
@@ -430,11 +442,11 @@ class AsyncGenTest(unittest.TestCase):
g
=
gen
()
self
.
assertEqual
(
g
.
__name__
,
'gen'
)
g
.
__name__
=
'123'
g
.
__name__
=
'123'
if
sys
.
version_info
[
0
]
>=
3
else
b'123'
self
.
assertEqual
(
g
.
__name__
,
'123'
)
self
.
assertIn
(
'.gen'
,
g
.
__qualname__
)
g
.
__qualname__
=
'123'
g
.
__qualname__
=
'123'
if
sys
.
version_info
[
0
]
>=
3
else
b'123'
self
.
assertEqual
(
g
.
__qualname__
,
'123'
)
#self.assertIsNone(g.ag_await)
...
...
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