Fix one more ctypes test, and disable the tests that were segfaulting.
Thanks to Christian Heimes for finding these tests.
This commit is contained in:
parent
c92159aaea
commit
f5af466d3a
|
@ -160,6 +160,8 @@ class FunctionTestCase(unittest.TestCase):
|
|||
result = f(1, 2, 3, 4, 5.0, 6.0, 21)
|
||||
self.failUnlessEqual(result, 42)
|
||||
|
||||
from ctypes.test import is_resource_enabled
|
||||
if is_resource_enabled("struni-crash"):
|
||||
def test_stringresult(self):
|
||||
f = dll._testfunc_p_p
|
||||
f.argtypes = None
|
||||
|
|
|
@ -41,17 +41,17 @@ class PythonAPITestCase(unittest.TestCase):
|
|||
# This test is unreliable, because it is possible that code in
|
||||
# unittest changes the refcount of the '42' integer. So, it
|
||||
# is disabled by default.
|
||||
def test_PyInt_Long(self):
|
||||
def test_PyLong_Long(self):
|
||||
ref42 = grc(42)
|
||||
pythonapi.PyInt_FromLong.restype = py_object
|
||||
self.failUnlessEqual(pythonapi.PyInt_FromLong(42), 42)
|
||||
pythonapi.PyLong_FromLong.restype = py_object
|
||||
self.failUnlessEqual(pythonapi.PyLong_FromLong(42), 42)
|
||||
|
||||
self.failUnlessEqual(grc(42), ref42)
|
||||
|
||||
pythonapi.PyInt_AsLong.argtypes = (py_object,)
|
||||
pythonapi.PyInt_AsLong.restype = c_long
|
||||
pythonapi.PyLong_AsLong.argtypes = (py_object,)
|
||||
pythonapi.PyLong_AsLong.restype = c_long
|
||||
|
||||
res = pythonapi.PyInt_AsLong(42)
|
||||
res = pythonapi.PyLong_AsLong(42)
|
||||
self.failUnlessEqual(grc(res), ref42 + 1)
|
||||
del res
|
||||
self.failUnlessEqual(grc(42), ref42)
|
||||
|
@ -67,6 +67,8 @@ class PythonAPITestCase(unittest.TestCase):
|
|||
del pyobj
|
||||
self.failUnlessEqual(grc(s), ref)
|
||||
|
||||
from ctypes.test import is_resource_enabled
|
||||
if is_resource_enabled("struni-crash"):
|
||||
def test_PyOS_snprintf(self):
|
||||
PyOS_snprintf = pythonapi.PyOS_snprintf
|
||||
PyOS_snprintf.argtypes = POINTER(c_char), c_size_t, c_char_p
|
||||
|
@ -75,7 +77,7 @@ class PythonAPITestCase(unittest.TestCase):
|
|||
PyOS_snprintf(buf, sizeof(buf), "Hello from %s", "ctypes")
|
||||
self.failUnlessEqual(buf.value, "Hello from ctypes")
|
||||
|
||||
PyOS_snprintf(buf, sizeof(buf), "Hello from %s", "ctypes", 1, 2, 3)
|
||||
PyOS_snprintf(buf, sizeof(buf), "Hello from %s (%d, %d, %d)", "ctypes", 1, 2, 3)
|
||||
self.failUnlessEqual(buf.value, "Hello from ctypes")
|
||||
|
||||
# not enough arguments
|
||||
|
|
|
@ -34,6 +34,8 @@ class SlicesTestCase(unittest.TestCase):
|
|||
# ValueError: Can only assign sequence of same size
|
||||
self.assertRaises(ValueError, setslice, a, 0, 5, range(32))
|
||||
|
||||
from ctypes.test import is_resource_enabled
|
||||
if is_resource_enabled("struni-crash"):
|
||||
def test_char_ptr(self):
|
||||
s = "abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
|
|
Loading…
Reference in New Issue