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
65408e6c
Commit
65408e6c
authored
Feb 13, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix doctests in 32bit Py2.x
parent
4dd8e762
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
16 deletions
+42
-16
tests/run/carray_coercion.pyx
tests/run/carray_coercion.pyx
+19
-4
tests/run/reversed_iteration.pyx
tests/run/reversed_iteration.pyx
+23
-12
No files found.
tests/run/carray_coercion.pyx
View file @
65408e6c
# mode: run
import
sys
IS_PY3
=
sys
.
version_info
[
0
]
>=
3
IS_32BIT_PY2
=
not
IS_PY3
and
sys
.
maxint
<
2
**
32
def
unlongify
(
v
):
# on 32bit Py2.x platforms, 'unsigned int' coerces to a Python long => fix doctest output here.
s
=
repr
(
v
)
if
IS_32BIT_PY2
:
assert
s
.
count
(
'L'
)
==
s
.
count
(
','
)
+
1
,
s
s
=
s
.
replace
(
'L'
,
''
)
return
s
def
from_int_array
():
"""
...
...
@@ -30,8 +45,8 @@ cdef extern from "stdint.h":
def
from_typedef_int_array
():
"""
>>>
from_typedef_int_array(
)
[1, 2, 3]
>>>
unlongify(from_typedef_int_array()
)
'[1, 2, 3]'
"""
cdef
uint32_t
[
3
]
v
v
[
0
]
=
1
...
...
@@ -42,8 +57,8 @@ def from_typedef_int_array():
cpdef
tuple
tuple_from_typedef_int_array
():
"""
>>>
tuple_from_typedef_int_array(
)
(1, 2, 3)
>>>
unlongify(tuple_from_typedef_int_array()
)
'(1, 2, 3)'
"""
cdef
uint32_t
[
3
]
v
v
[
0
]
=
1
...
...
tests/run/reversed_iteration.pyx
View file @
65408e6c
...
...
@@ -5,6 +5,17 @@ cimport cython
import
sys
IS_PY3
=
sys
.
version_info
[
0
]
>=
3
IS_32BIT_PY2
=
not
IS_PY3
and
sys
.
maxint
<
2
**
32
def
unlongify
(
v
):
# on 32bit Py2.x platforms, 'unsigned int' coerces to a Python long => fix doctest output here.
s
=
repr
(
v
)
if
IS_32BIT_PY2
:
assert
s
.
count
(
'L'
)
==
s
.
count
(
','
)
+
1
,
s
s
=
s
.
replace
(
'L'
,
''
)
return
s
def
_reversed
(
it
):
return
list
(
it
)[::
-
1
]
...
...
@@ -764,10 +775,10 @@ def reversed_bytes_slice_step_only(bytes s):
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
def
reversed_unsigned
(
int
a
,
int
b
):
"""
>>>
reversed_unsigned(0, 5
)
[4, 3, 2, 1, 0]
>>>
reversed_unsigned(1, 5
)
[4, 3, 2, 1]
>>>
unlongify(reversed_unsigned(0, 5)
)
'[4, 3, 2, 1, 0]'
>>>
unlongify(reversed_unsigned(1, 5)
)
'[4, 3, 2, 1]'
>>> reversed_unsigned(1, 1)
[]
"""
...
...
@@ -777,10 +788,10 @@ def reversed_unsigned(int a, int b):
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
def
reversed_unsigned_by_3
(
int
a
,
int
b
):
"""
>>>
reversed_unsigned_by_3(0, 5
)
[3, 0]
>>>
reversed_unsigned_by_3(0, 7
)
[6, 3, 0]
>>>
unlongify(reversed_unsigned_by_3(0, 5)
)
'[3, 0]'
>>>
unlongify(reversed_unsigned_by_3(0, 7)
)
'[6, 3, 0]'
"""
cdef
unsigned
int
i
return
[
i
for
i
in
reversed
(
range
(
a
,
b
,
3
))]
...
...
@@ -788,10 +799,10 @@ def reversed_unsigned_by_3(int a, int b):
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
def
range_unsigned_by_neg_3
(
int
a
,
int
b
):
"""
>>>
range_unsigned_by_neg_3(-1, 6
)
[6, 3, 0]
>>>
range_unsigned_by_neg_3(0, 7
)
[7, 4, 1]
>>>
unlongify(range_unsigned_by_neg_3(-1, 6)
)
'[6, 3, 0]'
>>>
unlongify(range_unsigned_by_neg_3(0, 7)
)
'[7, 4, 1]'
"""
cdef
unsigned
int
i
return
[
i
for
i
in
range
(
b
,
a
,
-
3
)]
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