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
Kirill Smelkov
cython
Commits
346243fe
Commit
346243fe
authored
Apr 17, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.22.x'
parents
0921b9bc
5c85653f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
17 deletions
+19
-17
tests/run/unpack.pyx
tests/run/unpack.pyx
+19
-17
No files found.
tests/run/unpack.pyx
View file @
346243fe
...
...
@@ -3,12 +3,12 @@
import
cython
_set
=
set
def
_it
(
N
):
for
i
in
range
(
N
):
yield
i
cdef
class
ItCount
(
object
):
cdef
object
values
cdef
readonly
count
...
...
@@ -89,9 +89,9 @@ def unpack_partial(it):
"""
>>> it = _it(2)
>>> a = b = c = 0
>>> a,b,c = it
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
>>>
try:
a,b,c = it
... except ValueError: pass
... else: print("DID NOT FAIL!")
>>> a, b, c
(0, 0, 0)
>>> unpack_partial([1,2])
...
...
@@ -103,9 +103,9 @@ def unpack_partial(it):
>>> it = ItCount([1,2])
>>> a = b = c = 0
>>> a,b,c = it
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
>>>
try:
a,b,c = it
... except ValueError: pass
... else: print("DID NOT FAIL!")
>>> a, b, c
(0, 0, 0)
>>> it.count
...
...
@@ -153,7 +153,7 @@ def unpack_partial_typed(it):
(0, 0, 0)
>>> unpack_partial_typed((1, 'abc', 3))
(0, 0, 0)
>>> unpack_partial_typed(
_
set([1, 'abc', 3]))
>>> unpack_partial_typed(set([1, 'abc', 3]))
(0, 0, 0)
>>> it = ItCount([1, 'abc', 3])
...
...
@@ -222,10 +222,10 @@ def failure_too_many(it):
Traceback (most recent call last):
ValueError: too many values to unpack (expected 3)
>>> a,b,c =
_
set([1,2,3,4]) # doctest: +ELLIPSIS
>>> a,b,c = set([1,2,3,4]) # doctest: +ELLIPSIS
Traceback (most recent call last):
ValueError: too many values to unpack...
>>> failure_too_many(
_
set([1,2,3,4]))
>>> failure_too_many(set([1,2,3,4]))
Traceback (most recent call last):
ValueError: too many values to unpack (expected 3)
...
...
@@ -239,6 +239,7 @@ def failure_too_many(it):
a
,
b
,
c
=
it
return
a
,
b
,
c
def
failure_too_few
(
it
):
"""
>>> try: a,b,c = [1,2]
...
...
@@ -253,16 +254,16 @@ def failure_too_few(it):
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
>>>
a,b,c = _
set([1,2])
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
>>> failure_too_few(
_
set([1,2]))
>>>
try: a,b,c =
set([1,2])
... except ValueError: pass
... else: print("DID NOT FAIL!")
>>> failure_too_few(set([1,2]))
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
>>> a,b,c = _it(2)
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
>>>
try:
a,b,c = _it(2)
... except ValueError: pass
... else: print("DID NOT FAIL!")
>>> failure_too_few(_it(2))
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
...
...
@@ -270,6 +271,7 @@ def failure_too_few(it):
a
,
b
,
c
=
it
return
a
,
b
,
c
def
_it_failure
(
N
):
for
i
in
range
(
N
):
yield
i
...
...
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