Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xavier Thompson
cython
Commits
a1318767
Commit
a1318767
authored
12 years ago
by
Stefan Behnel
Browse files
Options
Download
Email Patches
Plain Diff
Py3 test fixes
parent
fb20e46c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
tests/run/cpp_stl_conversion.pyx
tests/run/cpp_stl_conversion.pyx
+9
-5
No files found.
tests/run/cpp_stl_conversion.pyx
View file @
a1318767
...
...
@@ -9,6 +9,8 @@ from libcpp.vector cimport vector
from
libcpp.list
cimport
list
as
cpp_list
py_set
=
set
py_xrange
=
xrange
py_unicode
=
unicode
cdef
string
add_strings
(
string
a
,
string
b
):
return
a
+
b
...
...
@@ -49,11 +51,11 @@ def test_encode_to_string_cast(o):
s
=
<
string
>
o
.
encode
(
'ascii'
)
return
s
def
test_
bytes
_encode_to_string
(
bytes
o
):
def
test_
unicode
_encode_to_string
(
unicode
o
):
"""
>>> normalize(test_
bytes
_encode_to_string('abc'))
>>> normalize(test_
unicode
_encode_to_string(
py_unicode(
'abc'))
)
'abc'
>>> normalize(test_
bytes
_encode_to_string('abc
\\
x00def'))
>>> normalize(test_
unicode
_encode_to_string(
py_unicode(
'abc
\\
x00def'))
)
'abc
\\
x00def'
"""
cdef
string
s
=
o
.
encode
(
'ascii'
)
...
...
@@ -72,6 +74,8 @@ def test_int_vector(o):
[1, 2, 3]
>>> test_int_vector((1, 10, 100))
[1, 10, 100]
>>> test_int_vector(py_xrange(1,10,2))
[1, 3, 5, 7, 9]
>>> test_int_vector([10**20]) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
...
...
@@ -82,7 +86,7 @@ def test_int_vector(o):
def
test_string_vector
(
s
):
"""
>>> map(normalize, test_string_vector('ab cd ef gh'.encode('ascii')))
>>>
list(
map(normalize, test_string_vector('ab cd ef gh'.encode('ascii')))
)
['ab', 'cd', 'ef', 'gh']
"""
cdef
vector
[
string
]
cpp_strings
=
s
.
split
()
...
...
@@ -93,7 +97,7 @@ cdef list convert_string_vector(vector[string] vect):
def
test_string_vector_temp_funcarg
(
s
):
"""
>>> map(normalize, test_string_vector_temp_funcarg('ab cd ef gh'.encode('ascii')))
>>>
list(
map(normalize, test_string_vector_temp_funcarg('ab cd ef gh'.encode('ascii')))
)
['ab', 'cd', 'ef', 'gh']
"""
return
convert_string_vector
(
s
.
split
())
...
...
This diff is collapsed.
Click to expand it.
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