[pypy-svn] pypy default: add a poor's man "xfail" to ctypes test, and mark all known-to-fail ones. This

antocuni commits-noreply at bitbucket.org
Mon Jan 17 19:23:36 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r40811:631d92df31b4
Date: 2011-01-17 19:22 +0100
http://bitbucket.org/pypy/pypy/changeset/631d92df31b4/

Log:	add a poor's man "xfail" to ctypes test, and mark all known-to-fail
	ones. This way, it will be easier to spot "real" regressions in
	jitypes2. There is also a new "test_no_more_xfail" test that will
	fail until all xfail will be removed, so we don't forget about them

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_varsize_struct.py b/lib-python/modified-2.7.0/ctypes/test/test_varsize_struct.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_varsize_struct.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_varsize_struct.py
@@ -1,7 +1,9 @@
 from ctypes import *
 import unittest
+from ctypes.test import xfail
 
 class VarSizeTest(unittest.TestCase):
+    @xfail
     def test_resize(self):
         class X(Structure):
             _fields_ = [("item", c_int),

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_simplesubclasses.py b/lib-python/modified-2.7.0/ctypes/test/test_simplesubclasses.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_simplesubclasses.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_simplesubclasses.py
@@ -1,5 +1,6 @@
 import unittest
 from ctypes import *
+from ctypes.test import xfail
 
 class MyInt(c_int):
     def __cmp__(self, other):
@@ -26,6 +27,7 @@
         self.assertEqual(None, cb())
 
 
+    @xfail
     def test_int_callback(self):
         args = []
         def func(arg):

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_cast.py b/lib-python/modified-2.7.0/ctypes/test/test_cast.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_cast.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_cast.py
@@ -2,6 +2,8 @@
 import unittest
 import sys
 
+from ctypes.test import xfail
+
 class Test(unittest.TestCase):
 
     def test_array2pointer(self):
@@ -20,6 +22,7 @@
                 self.assertEqual([ptr[i] for i in range(6)],
                                      [0, 42, 0, 17, 0, 2])
 
+    @xfail
     def test_address2pointer(self):
         array = (c_int * 3)(42, 17, 2)
 

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_init.py b/lib-python/modified-2.7.0/ctypes/test/test_init.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_init.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_init.py
@@ -1,5 +1,6 @@
 from ctypes import *
 import unittest
+from ctypes.test import xfail
 
 class X(Structure):
     _fields_ = [("a", c_int),
@@ -20,6 +21,7 @@
 
 
 class InitTest(unittest.TestCase):
+    @xfail
     def test_get(self):
         # make sure the only accessing a nested structure
         # doesn't call the structure's __new__ and __init__

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_prototypes.py b/lib-python/modified-2.7.0/ctypes/test/test_prototypes.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_prototypes.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_prototypes.py
@@ -1,5 +1,6 @@
 from ctypes import *
 import unittest
+from ctypes.test import xfail
 
 # IMPORTANT INFO:
 #
@@ -48,6 +49,7 @@
         func.restype = c_long
         func.argtypes = None
 
+    @xfail
     def test_paramflags(self):
         # function returns c_void_p result,
         # and has a required parameter named 'input'

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_stringptr.py b/lib-python/modified-2.7.0/ctypes/test/test_stringptr.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_stringptr.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_stringptr.py
@@ -2,11 +2,13 @@
 from ctypes import *
 
 import _ctypes_test
+from ctypes.test import xfail
 
 lib = CDLL(_ctypes_test.__file__)
 
 class StringPtrTestCase(unittest.TestCase):
 
+    @xfail
     def test__POINTER_c_char(self):
         class X(Structure):
             _fields_ = [("str", POINTER(c_char))]
@@ -27,6 +29,7 @@
 
         self.assertRaises(TypeError, setattr, x, "str", "Hello, World")
 
+    @xfail
     def test__c_char_p(self):
         class X(Structure):
             _fields_ = [("str", c_char_p)]

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_pep3118.py b/lib-python/modified-2.7.0/ctypes/test/test_pep3118.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_pep3118.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_pep3118.py
@@ -1,6 +1,7 @@
 import unittest
 from ctypes import *
 import re, sys
+from ctypes.test import xfail
 
 if sys.byteorder == "little":
     THIS_ENDIAN = "<"
@@ -19,6 +20,7 @@
 
 class Test(unittest.TestCase):
 
+    @xfail
     def test_native_types(self):
         for tp, fmt, shape, itemtp in native_types:
             ob = tp()
@@ -46,6 +48,7 @@
                 print(tp)
                 raise
 
+    @xfail
     def test_endian_types(self):
         for tp, fmt, shape, itemtp in endian_types:
             ob = tp()

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_refcounts.py b/lib-python/modified-2.7.0/ctypes/test/test_refcounts.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_refcounts.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_refcounts.py
@@ -1,6 +1,7 @@
 import unittest
 import ctypes
 import gc
+from ctypes.test import xfail
 
 MyCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int)
 OtherCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong)
@@ -82,6 +83,7 @@
         self.assertEqual(grc(func), 2)
 
 class AnotherLeak(unittest.TestCase):
+    @xfail
     def test_callback(self):
         import sys
 

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_bitfields.py b/lib-python/modified-2.7.0/ctypes/test/test_bitfields.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_bitfields.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_bitfields.py
@@ -4,6 +4,7 @@
 
 import ctypes
 import _ctypes_test
+from ctypes.test import xfail
 
 class BITS(Structure):
     _fields_ = [("A", c_int, 1),
@@ -112,6 +113,7 @@
         return self.get_except(type(Structure), "X", (),
                                {"_fields_": fields})
 
+    @xfail
     def test_nonint_types(self):
         # bit fields are not allowed on non-integer types.
         result = self.fail_fields(("a", c_char_p, 1))
@@ -141,6 +143,7 @@
         result = self.fail_fields(("a", Dummy, 1))
         self.assertEqual(result, (TypeError, 'bit fields not allowed for type Dummy'))
 
+    @xfail
     def test_single_bitfield_size(self):
         for c_typ in int_types:
             result = self.fail_fields(("a", c_typ, -1))

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_pickling.py b/lib-python/modified-2.7.0/ctypes/test/test_pickling.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_pickling.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_pickling.py
@@ -3,6 +3,7 @@
 from ctypes import *
 import _ctypes_test
 dll = CDLL(_ctypes_test.__file__)
+from ctypes.test import xfail
 
 class X(Structure):
     _fields_ = [("a", c_int), ("b", c_double)]
@@ -21,6 +22,7 @@
     def loads(self, item):
         return pickle.loads(item)
 
+    @xfail
     def test_simple(self):
         for src in [
             c_int(42),
@@ -31,6 +33,7 @@
             self.assertEqual(memoryview(src).tobytes(),
                                  memoryview(dst).tobytes())
 
+    @xfail
     def test_struct(self):
         X.init_called = 0
 
@@ -49,6 +52,7 @@
         self.assertEqual(memoryview(y).tobytes(),
                              memoryview(x).tobytes())
 
+    @xfail
     def test_unpickable(self):
         # ctypes objects that are pointers or contain pointers are
         # unpickable.
@@ -66,6 +70,7 @@
             ]:
             self.assertRaises(ValueError, lambda: self.dumps(item))
 
+    @xfail
     def test_wchar(self):
         pickle.dumps(c_char("x"))
         # Issue 5049

diff --git a/lib-python/modified-2.7.0/ctypes/test/__init__.py b/lib-python/modified-2.7.0/ctypes/test/__init__.py
--- a/lib-python/modified-2.7.0/ctypes/test/__init__.py
+++ b/lib-python/modified-2.7.0/ctypes/test/__init__.py
@@ -206,3 +206,16 @@
         result = unittest.TestResult()
         test(result)
         return result
+
+def xfail(method):
+    """
+    Poor's man xfail: remove it when all the failures have been fixed
+    """
+    def new_method(self):
+        try:
+            method(self)
+        except:
+            pass
+        else:
+            self.assertTrue(False, "DID NOT RAISE")
+    return new_method

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_strings.py b/lib-python/modified-2.7.0/ctypes/test/test_strings.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_strings.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_strings.py
@@ -1,6 +1,7 @@
 import unittest
 from ctypes import *
 from test import test_support
+from ctypes.test import xfail
 
 class StringArrayTestCase(unittest.TestCase):
     def test(self):
@@ -25,6 +26,7 @@
         self.assertRaises(ValueError, setattr, buf, "value", "aaaaaaaa")
         self.assertRaises(TypeError, setattr, buf, "value", 42)
 
+    @xfail
     def test_c_buffer_value(self, memoryview=memoryview):
         buf = c_buffer(32)
 
@@ -35,6 +37,7 @@
         self.assertRaises(TypeError, setattr, buf, "value", memoryview("abc"))
         self.assertRaises(ValueError, setattr, buf, "raw", memoryview("x" * 100))
 
+    @xfail
     def test_c_buffer_raw(self, memoryview=memoryview):
         buf = c_buffer(32)
 
@@ -43,6 +46,7 @@
         self.assertRaises(TypeError, setattr, buf, "value", memoryview("abc"))
         self.assertRaises(ValueError, setattr, buf, "raw", memoryview("x" * 100))
 
+    @xfail
     def test_c_buffer_deprecated(self):
         # Compatibility with 2.x
         with test_support.check_py3k_warnings():

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_python_api.py b/lib-python/modified-2.7.0/ctypes/test/test_python_api.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_python_api.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_python_api.py
@@ -1,6 +1,6 @@
 from ctypes import *
 import unittest, sys
-from ctypes.test import is_resource_enabled
+from ctypes.test import is_resource_enabled, xfail
 
 ################################################################
 # This section should be moved into ctypes\__init__.py, when it's ready.
@@ -17,6 +17,7 @@
 
 class PythonAPITestCase(unittest.TestCase):
 
+    @xfail
     def test_PyString_FromStringAndSize(self):
         PyString_FromStringAndSize = pythonapi.PyString_FromStringAndSize
 
@@ -25,6 +26,7 @@
 
         self.assertEqual(PyString_FromStringAndSize("abcdefghi", 3), "abc")
 
+    @xfail
     def test_PyString_FromString(self):
         pythonapi.PyString_FromString.restype = py_object
         pythonapi.PyString_FromString.argtypes = (c_char_p,)
@@ -56,6 +58,7 @@
             del res
             self.assertEqual(grc(42), ref42)
 
+    @xfail
     def test_PyObj_FromPtr(self):
         s = "abc def ghi jkl"
         ref = grc(s)
@@ -81,6 +84,7 @@
         # not enough arguments
         self.assertRaises(TypeError, PyOS_snprintf, buf)
 
+    @xfail
     def test_pyobject_repr(self):
         self.assertEqual(repr(py_object()), "py_object(<NULL>)")
         self.assertEqual(repr(py_object(42)), "py_object(42)")

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_functions.py b/lib-python/modified-2.7.0/ctypes/test/test_functions.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_functions.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_functions.py
@@ -7,6 +7,7 @@
 
 from ctypes import *
 import sys, unittest
+from ctypes.test import xfail
 
 try:
     WINFUNCTYPE
@@ -393,6 +394,7 @@
             self.assertEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
                                  (9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))
 
+    @xfail
     def test_sf1651235(self):
         # see http://www.python.org/sf/1651235
 

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_frombuffer.py b/lib-python/modified-2.7.0/ctypes/test/test_frombuffer.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_frombuffer.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_frombuffer.py
@@ -2,6 +2,7 @@
 import array
 import gc
 import unittest
+from ctypes.test import xfail
 
 class X(Structure):
     _fields_ = [("c_int", c_int)]
@@ -10,6 +11,7 @@
         self._init_called = True
 
 class Test(unittest.TestCase):
+    @xfail
     def test_fom_buffer(self):
         a = array.array("i", range(16))
         x = (c_int * 16).from_buffer(a)
@@ -35,6 +37,7 @@
         self.assertRaises(TypeError,
                           (c_char * 16).from_buffer, "a" * 16)
 
+    @xfail
     def test_fom_buffer_with_offset(self):
         a = array.array("i", range(16))
         x = (c_int * 15).from_buffer(a, sizeof(c_int))
@@ -43,6 +46,7 @@
         self.assertRaises(ValueError, lambda: (c_int * 16).from_buffer(a, sizeof(c_int)))
         self.assertRaises(ValueError, lambda: (c_int * 1).from_buffer(a, 16 * sizeof(c_int)))
 
+    @xfail
     def test_from_buffer_copy(self):
         a = array.array("i", range(16))
         x = (c_int * 16).from_buffer_copy(a)
@@ -67,6 +71,7 @@
         x = (c_char * 16).from_buffer_copy("a" * 16)
         self.assertEqual(x[:], "a" * 16)
 
+    @xfail
     def test_fom_buffer_copy_with_offset(self):
         a = array.array("i", range(16))
         x = (c_int * 15).from_buffer_copy(a, sizeof(c_int))

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_byteswap.py b/lib-python/modified-2.7.0/ctypes/test/test_byteswap.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_byteswap.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_byteswap.py
@@ -2,6 +2,7 @@
 from binascii import hexlify
 
 from ctypes import *
+from ctypes.test import xfail
 
 def bin(s):
     return hexlify(memoryview(s)).upper()
@@ -21,6 +22,7 @@
             setattr(bits, "i%s" % i, 1)
             dump(bits)
 
+    @xfail
     def test_endian_short(self):
         if sys.byteorder == "little":
             self.assertTrue(c_short.__ctype_le__ is c_short)
@@ -48,6 +50,7 @@
         self.assertEqual(bin(s), "3412")
         self.assertEqual(s.value, 0x1234)
 
+    @xfail
     def test_endian_int(self):
         if sys.byteorder == "little":
             self.assertTrue(c_int.__ctype_le__ is c_int)
@@ -76,6 +79,7 @@
         self.assertEqual(bin(s), "78563412")
         self.assertEqual(s.value, 0x12345678)
 
+    @xfail
     def test_endian_longlong(self):
         if sys.byteorder == "little":
             self.assertTrue(c_longlong.__ctype_le__ is c_longlong)
@@ -104,6 +108,7 @@
         self.assertEqual(bin(s), "EFCDAB9078563412")
         self.assertEqual(s.value, 0x1234567890ABCDEF)
 
+    @xfail
     def test_endian_float(self):
         if sys.byteorder == "little":
             self.assertTrue(c_float.__ctype_le__ is c_float)
@@ -122,6 +127,7 @@
         self.assertAlmostEqual(s.value, math.pi, 6)
         self.assertEqual(bin(struct.pack(">f", math.pi)), bin(s))
 
+    @xfail
     def test_endian_double(self):
         if sys.byteorder == "little":
             self.assertTrue(c_double.__ctype_le__ is c_double)
@@ -149,6 +155,7 @@
         self.assertTrue(c_char.__ctype_le__ is c_char)
         self.assertTrue(c_char.__ctype_be__ is c_char)
 
+    @xfail
     def test_struct_fields_1(self):
         if sys.byteorder == "little":
             base = BigEndianStructure
@@ -198,6 +205,7 @@
             pass
         self.assertRaises(TypeError, setattr, S, "_fields_", [("s", T)])
 
+    @xfail
     def test_struct_fields_2(self):
         # standard packing in struct uses no alignment.
         # So, we have to align using pad bytes.
@@ -221,6 +229,7 @@
         s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14)
         self.assertEqual(bin(s1), bin(s2))
 
+    @xfail
     def test_unaligned_nonnative_struct_fields(self):
         if sys.byteorder == "little":
             base = BigEndianStructure

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_libc.py b/lib-python/modified-2.7.0/ctypes/test/test_libc.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_libc.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_libc.py
@@ -25,5 +25,10 @@
         lib.my_qsort(chars, len(chars)-1, sizeof(c_char), comparefunc(sort))
         self.assertEqual(chars.raw, "   ,,aaaadmmmnpppsss\x00")
 
+    def test_no_more_xfail(self):
+        import ctypes.test
+        self.assertTrue(not hasattr(ctypes.test, 'xfail'),
+                        "You should incrementally grep for '@xfail' and remove them, they are real failures")
+
 if __name__ == "__main__":
     unittest.main()

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_internals.py b/lib-python/modified-2.7.0/ctypes/test/test_internals.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_internals.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_internals.py
@@ -2,6 +2,7 @@
 import unittest
 from ctypes import *
 from sys import getrefcount as grc
+from ctypes.test import xfail
 
 # XXX This test must be reviewed for correctness!!!
 
@@ -28,6 +29,7 @@
         self.assertEqual(refcnt, grc(i))
         self.assertEqual(ci._objects, None)
 
+    @xfail
     def test_c_char_p(self):
         s = "Hello, World"
         refcnt = grc(s)

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_callbacks.py b/lib-python/modified-2.7.0/ctypes/test/test_callbacks.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_callbacks.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_callbacks.py
@@ -1,6 +1,7 @@
 import unittest
 from ctypes import *
 import _ctypes_test
+from ctypes.test import xfail
 
 class Callbacks(unittest.TestCase):
     functype = CFUNCTYPE
@@ -98,6 +99,7 @@
 ##        self.check_type(c_char_p, "abc")
 ##        self.check_type(c_char_p, "def")
 
+    @xfail
     def test_pyobject(self):
         o = ()
         from sys import getrefcount as grc
@@ -124,6 +126,7 @@
         prototype = self.functype.im_func(object)
         self.assertRaises(TypeError, prototype, lambda: None)
 
+    @xfail
     def test_issue_7959(self):
         proto = self.functype.im_func(None)
 

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_numbers.py b/lib-python/modified-2.7.0/ctypes/test/test_numbers.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_numbers.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_numbers.py
@@ -1,6 +1,7 @@
 from ctypes import *
 import unittest
 import struct
+from ctypes.test import xfail
 
 def valid_ranges(*types):
     # given a sequence of numeric types, collect their _type_
@@ -89,12 +90,14 @@
 ##            self.assertRaises(ValueError, t, l-1)
 ##            self.assertRaises(ValueError, t, h+1)
 
+    @xfail
     def test_from_param(self):
         # the from_param class method attribute always
         # returns PyCArgObject instances
         for t in signed_types + unsigned_types + float_types:
             self.assertEqual(ArgType, type(t.from_param(0)))
 
+    @xfail
     def test_byref(self):
         # calling byref returns also a PyCArgObject instance
         for t in signed_types + unsigned_types + float_types + bool_types:
@@ -102,6 +105,7 @@
             self.assertEqual(ArgType, type(parm))
 
 
+    @xfail
     def test_floats(self):
         # c_float and c_double can be created from
         # Python int, long and float
@@ -115,6 +119,7 @@
             self.assertEqual(t(2L).value, 2.0)
             self.assertEqual(t(f).value, 2.0)
 
+    @xfail
     def test_integers(self):
         class FloatLike(object):
             def __float__(self):

diff --git a/lib-python/modified-2.7.0/ctypes/test/test_parameters.py b/lib-python/modified-2.7.0/ctypes/test/test_parameters.py
--- a/lib-python/modified-2.7.0/ctypes/test/test_parameters.py
+++ b/lib-python/modified-2.7.0/ctypes/test/test_parameters.py
@@ -1,5 +1,7 @@
 import unittest, sys
 
+from ctypes.test import xfail
+
 class SimpleTypesTestCase(unittest.TestCase):
 
     def setUp(self):
@@ -49,6 +51,7 @@
         self.assertEqual(CWCHARP.from_param("abc"), "abcabcabc")
 
     # XXX Replace by c_char_p tests
+    @xfail
     def test_cstrings(self):
         from ctypes import c_char_p, byref
 
@@ -87,6 +90,7 @@
         pa = c_wchar_p.from_param(c_wchar_p(u"123"))
         self.assertEqual(type(pa), c_wchar_p)
 
+    @xfail
     def test_int_pointers(self):
         from ctypes import c_short, c_uint, c_int, c_long, POINTER, pointer
         LPINT = POINTER(c_int)


More information about the Pypy-commit mailing list