Source

cffi / testing / test_ffi_backend.py

Full commit
Armin Rigo da8b284 
Armin Rigo 15dc0c6 
Armin Rigo da8b284 
Armin Rigo 232154d 
Armin Rigo d3d6904 

Armin Rigo 15dc0c6 


Armin Rigo fec880d 
Armin Rigo d3d6904 


Armin Rigo 232154d 
Armin Rigo da8b284 


Armin Rigo d61a612 
Armin Rigo da8b284 



Armin Rigo bde32d4 


Armin Rigo d63ceb2 


import py
from testing import backend_tests, test_function, test_ownlib
from cffi import FFI
import _cffi_backend


class TestFFI(backend_tests.BackendTests,
              test_function.TestFunction,
              test_ownlib.TestOwnLib):
    TypeRepr = "<ctype '%s'>"

    @staticmethod
    def Backend():
        return _cffi_backend

    def test_not_supported_bitfield_in_result(self):
        ffi = FFI(backend=self.Backend())
        ffi.cdef("struct foo_s { int a,b,c,d,e; int x:1; };")
        e = py.test.raises(NotImplementedError, ffi.callback,
                           "struct foo_s foo(void)", lambda: 42)
        assert str(e.value) == ("<struct foo_s(*)(void)>: "
            "cannot pass as argument or return value a struct with bit fields")

    def test_inspecttype(self):
        ffi = FFI(backend=self.Backend())
        assert ffi.typeof("long").kind == "primitive"
        assert ffi.typeof("long(*)(long, long**, ...)").cname == (
            "long(*)(long, long * *, ...)")
        assert ffi.typeof("long(*)(long, long**, ...)").ellipsis is True