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
a471b0ca
Commit
a471b0ca
authored
Jul 09, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adapt test to PyPy
parent
ac0a7365
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
tests/run/struct_conversion.pyx
tests/run/struct_conversion.pyx
+5
-3
No files found.
tests/run/struct_conversion.pyx
View file @
a471b0ca
...
...
@@ -78,9 +78,11 @@ cdef struct MyStruct:
float
f
char
*
s
bhello
=
b"hello"
# must hold a C reference in PyPy
def
test_obj_to_struct
(
MyStruct
mystruct
):
"""
>>> test_obj_to_struct(dict(c=10, i=20, f=6.7, s=b
"hello"
))
>>> test_obj_to_struct(dict(c=10, i=20, f=6.7, s=b
hello
))
c=10 i=20 f=6.70 s=hello
>>> test_obj_to_struct(None)
Traceback (most recent call last):
...
...
@@ -95,7 +97,7 @@ def test_obj_to_struct(MyStruct mystruct):
...
TypeError: an integer is required
"""
print
'c=%d i=%d f=%.2f s=%s'
%
(
mystruct
.
c
,
mystruct
.
i
,
mystruct
.
f
,
mystruct
.
s
.
decode
(
'
UTF-8
'
))
print
'c=%d i=%d f=%.2f s=%s'
%
(
mystruct
.
c
,
mystruct
.
i
,
mystruct
.
f
,
mystruct
.
s
.
decode
(
'
ascii
'
))
cdef
struct
NestedStruct
:
MyStruct
mystruct
...
...
@@ -103,7 +105,7 @@ cdef struct NestedStruct:
def
test_nested_obj_to_struct
(
NestedStruct
nested
):
"""
>>> test_nested_obj_to_struct(dict(mystruct=dict(c=10, i=20, f=6.7, s=b
"hello"
), d=4.5))
>>> test_nested_obj_to_struct(dict(mystruct=dict(c=10, i=20, f=6.7, s=b
hello
), d=4.5))
c=10 i=20 f=6.70 s=hello d=4.50
>>> test_nested_obj_to_struct(dict(d=7.6))
Traceback (most recent call last):
...
...
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