[pypy-svn] pypy jitypes2: fix test_numbers: neither the array nor the struct modules support the new "g"
antocuni
commits-noreply at bitbucket.org
Mon Jan 17 18:22:57 CET 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: jitypes2
Changeset: r40796:428e121f2013
Date: 2011-01-17 15:59 +0100
http://bitbucket.org/pypy/pypy/changeset/428e121f2013/
Log: fix test_numbers: neither the array nor the struct modules support
the new "g" typecode for long doubles. The fix is to just skip the
testcase when we need struct, and to use a _rawffi.Array instead of
an array.array
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_numbers.py b/pypy/module/test_lib_pypy/ctypes_tests/test_numbers.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_numbers.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_numbers.py
@@ -112,6 +112,9 @@
def test_sizes(self):
for t in signed_types + unsigned_types + float_types:
+ if t._type_ == 'g':
+ # typecode not supported by "struct"
+ continue
size = struct.calcsize(t._type_)
# sizeof of the type...
assert sizeof(t) == size
@@ -121,6 +124,9 @@
def test_alignments(self):
for t in signed_types + unsigned_types + float_types:
code = t._type_ # the typecode
+ if code == 'g':
+ # typecode not supported by "struct"
+ continue
align = struct.calcsize("c%c" % code) - struct.calcsize(code)
# alignment of the type...
@@ -150,15 +156,17 @@
def test_float_from_address(self):
- from array import array
+ from _rawffi import Array
for t in float_types:
- a = array(t._type_, [3.14])
- v = t.from_address(a.buffer_info()[0])
+ a = Array(t._type_)(1)
+ a[0] = 3.14
+ v = t.from_address(a.buffer)
assert v.value == a[0]
assert type(v) is t
a[0] = 2.3456e17
assert v.value == a[0]
assert type(v) is t
+ a.free()
def test_char_from_address(self):
from ctypes import c_char
More information about the Pypy-commit
mailing list