Commits

Armin Rigo  committed 5ba0cba

Skip the ffi.buffer() tests with the ctypes backend on top of PyPy.

  • Participants
  • Parent commits 901792f

Comments (0)

Files changed (2)

File cffi/backend_ctypes.py

 import ctypes, ctypes.util, operator, sys
 from . import model
-import sys
 
 if sys.version_info < (3,):
     integer_types = (int, long)
                 return view.cast('B')
 
         # haaaaaaaaaaaack
+        if '__pypy__' in sys.builtin_module_names:
+            raise NotImplementedError("PyPy: ffi.buffer() with ctypes backend")
         call = ctypes.pythonapi.PyBuffer_FromReadWriteMemory
         call.argtypes = (ctypes.c_void_p, ctypes.c_size_t)
         call.restype = ctypes.py_object

File testing/backend_tests.py

     def test_ffi_buffer_ptr(self):
         ffi = FFI(backend=self.Backend())
         a = ffi.new("short *", 100)
-        b = ffi.buffer(a)
+        try:
+            b = ffi.buffer(a)
+        except NotImplementedError as e:
+            py.test.skip(str(e))
         if sys.version < '3':
             assert type(b) is buffer
             content = str(b)
     def test_ffi_buffer_array(self):
         ffi = FFI(backend=self.Backend())
         a = ffi.new("int[]", list(range(100, 110)))
-        b = ffi.buffer(a)
+        try:
+            b = ffi.buffer(a)
+        except NotImplementedError as e:
+            py.test.skip(str(e))
         if sys.version < '3':
             assert type(b) is buffer
             content = str(b)
     def test_ffi_buffer_ptr_size(self):
         ffi = FFI(backend=self.Backend())
         a = ffi.new("short *", 0x4243)
-        b = ffi.buffer(a, 1)
+        try:
+            b = ffi.buffer(a, 1)
+        except NotImplementedError as e:
+            py.test.skip(str(e))
         if sys.version < '3':
             assert type(b) is buffer
             content = str(b)
         ffi = FFI(backend=self.Backend())
         a1 = ffi.new("int[]", list(range(100, 110)))
         a2 = ffi.new("int[]", list(range(100, 115)))
+        try:
+            ffi.buffer(a1)
+        except NotImplementedError as e:
+            py.test.skip(str(e))
         if sys.version < '3':
             assert str(ffi.buffer(a1)) == str(ffi.buffer(a2, 4*10))
         else:
         fd, filename = tempfile.mkstemp()
         f = os.fdopen(fd, 'r+b')
         a = ffi.new("int[]", list(range(1005)))
+        try:
+            ffi.buffer(a, 512)
+        except NotImplementedError as e:
+            py.test.skip(str(e))
         f.write(ffi.buffer(a, 1000 * ffi.sizeof("int")))
         f.seek(0)
         assert f.read() == array.array('i', range(1000)).tostring()