summaryrefslogtreecommitdiff
path: root/testing/cffi1/test_verify1.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/cffi1/test_verify1.py')
-rw-r--r--testing/cffi1/test_verify1.py184
1 files changed, 92 insertions, 92 deletions
diff --git a/testing/cffi1/test_verify1.py b/testing/cffi1/test_verify1.py
index 45df2b3..6245281 100644
--- a/testing/cffi1/test_verify1.py
+++ b/testing/cffi1/test_verify1.py
@@ -1,4 +1,4 @@
-import os, sys, math, py
+import os, sys, math
import pytest
from cffi import FFI, FFIError, VerificationError, VerificationMissing, model
from cffi import CDefError
@@ -63,10 +63,10 @@ def test_simple_case():
def _Wconversion(cdef, source, **kargs):
if sys.platform in ('win32', 'darwin'):
- py.test.skip("needs GCC")
+ pytest.skip("needs GCC")
ffi = FFI()
ffi.cdef(cdef)
- py.test.raises(VerificationError, ffi.verify, source, **kargs)
+ pytest.raises(VerificationError, ffi.verify, source, **kargs)
extra_compile_args_orig = extra_compile_args[:]
extra_compile_args.remove('-Wconversion')
try:
@@ -186,7 +186,7 @@ def test_longdouble_precision():
assert abs(more_precise - 0.656769) < 0.001
assert abs(less_precise - 3.99091) < 0.001
else:
- py.test.skip("don't know the very exact precision of 'long double'")
+ pytest.skip("don't know the very exact precision of 'long double'")
all_primitive_types = model.PrimitiveType.ALL_PRIMITIVE_TYPES
@@ -239,7 +239,7 @@ def test_all_integer_and_float_types():
if sys.version < '3':
assert foo(long(44)) == 45
assert foo(ffi.cast(typename, 46)) == 47
- py.test.raises(TypeError, foo, ffi.NULL)
+ pytest.raises(TypeError, foo, ffi.NULL)
#
# check for overflow cases
if all_primitive_types[typename] == 'f':
@@ -248,7 +248,7 @@ def test_all_integer_and_float_types():
2**5, 2**10, 2**20, 2**40, 2**80]:
overflows = int(ffi.cast(typename, value)) != value
if overflows:
- py.test.raises(OverflowError, foo, value)
+ pytest.raises(OverflowError, foo, value)
else:
assert foo(value) == value + 1
@@ -268,8 +268,8 @@ def test_var_signed_integer_types():
assert getattr(lib, varname) == max
setattr(lib, varname, min)
assert getattr(lib, varname) == min
- py.test.raises(OverflowError, setattr, lib, varname, max+1)
- py.test.raises(OverflowError, setattr, lib, varname, min-1)
+ pytest.raises(OverflowError, setattr, lib, varname, max+1)
+ pytest.raises(OverflowError, setattr, lib, varname, min-1)
def test_var_unsigned_integer_types():
ffi = FFI()
@@ -289,8 +289,8 @@ def test_var_unsigned_integer_types():
assert getattr(lib, varname) == max
setattr(lib, varname, 0)
assert getattr(lib, varname) == 0
- py.test.raises(OverflowError, setattr, lib, varname, max+1)
- py.test.raises(OverflowError, setattr, lib, varname, -1)
+ pytest.raises(OverflowError, setattr, lib, varname, max+1)
+ pytest.raises(OverflowError, setattr, lib, varname, -1)
def test_fn_signed_integer_types():
ffi = FFI()
@@ -309,8 +309,8 @@ def test_fn_signed_integer_types():
fn = getattr(lib, fnname)
assert fn(max) == max
assert fn(min) == min
- py.test.raises(OverflowError, fn, max + 1)
- py.test.raises(OverflowError, fn, min - 1)
+ pytest.raises(OverflowError, fn, max + 1)
+ pytest.raises(OverflowError, fn, min - 1)
def test_fn_unsigned_integer_types():
ffi = FFI()
@@ -331,16 +331,16 @@ def test_fn_unsigned_integer_types():
fn = getattr(lib, fnname)
assert fn(max) == max
assert fn(0) == 0
- py.test.raises(OverflowError, fn, max + 1)
- py.test.raises(OverflowError, fn, -1)
+ pytest.raises(OverflowError, fn, max + 1)
+ pytest.raises(OverflowError, fn, -1)
def test_char_type():
ffi = FFI()
ffi.cdef("char foo(char);")
lib = ffi.verify("char foo(char x) { return ++x; }")
assert lib.foo(b"A") == b"B"
- py.test.raises(TypeError, lib.foo, b"bar")
- py.test.raises(TypeError, lib.foo, "bar")
+ pytest.raises(TypeError, lib.foo, b"bar")
+ pytest.raises(TypeError, lib.foo, "bar")
def test_wchar_type():
ffi = FFI()
@@ -387,11 +387,11 @@ def test_bogus_ptr():
ffi = FFI()
ffi.cdef("int *foo(int *);")
lib = ffi.verify("int *foo(int *a) { return a; }")
- py.test.raises(TypeError, lib.foo, ffi.new("short *", 42))
+ pytest.raises(TypeError, lib.foo, ffi.new("short *", 42))
def test_verify_typedefs():
- py.test.skip("ignored so far")
+ pytest.skip("ignored so far")
types = ['signed char', 'unsigned char', 'int', 'long']
for cdefed in types:
for real in types:
@@ -400,7 +400,7 @@ def test_verify_typedefs():
if cdefed == real:
ffi.verify("typedef %s foo_t;" % real)
else:
- py.test.raises(VerificationError, ffi.verify,
+ pytest.raises(VerificationError, ffi.verify,
"typedef %s foo_t;" % real)
def test_nondecl_struct():
@@ -420,19 +420,19 @@ def test_ffi_full_struct():
check("struct foo_s { char x; int y; long *z; };")
#
if sys.platform != 'win32': # XXX fixme: only gives warnings
- py.test.raises(VerificationError, check,
+ pytest.raises(VerificationError, check,
"struct foo_s { char x; int y; int *z; };")
#
- py.test.raises(VerificationError, check,
+ pytest.raises(VerificationError, check,
"struct foo_s { int y; long *z; };") # cdef'ed field x is missing
#
- e = py.test.raises(FFI.error, check,
+ e = pytest.raises(FFI.error, check,
"struct foo_s { int y; char x; long *z; };")
assert str(e.value).startswith(
"struct foo_s: wrong offset for field 'x'"
" (cdef says 0, but C compiler says 4)")
#
- e = py.test.raises(FFI.error, check,
+ e = pytest.raises(FFI.error, check,
"struct foo_s { char x; int y; long *z; char extra; };")
assert str(e.value).startswith(
"struct foo_s: wrong total size"
@@ -445,7 +445,7 @@ def test_ffi_full_struct():
# that replaces what is just padding in our declaration above
check("struct foo_s { char x, extra; int y; long *z; };")
#
- e = py.test.raises(FFI.error, check,
+ e = pytest.raises(FFI.error, check,
"struct foo_s { char x; short pad; short y; long *z; };")
assert str(e.value).startswith(
"struct foo_s: wrong size for field 'y'"
@@ -459,9 +459,9 @@ def test_ffi_nonfull_struct():
...;
};
""")
- py.test.raises(VerificationMissing, ffi.sizeof, 'struct foo_s')
- py.test.raises(VerificationMissing, ffi.offsetof, 'struct foo_s', 'x')
- py.test.raises(VerificationMissing, ffi.new, 'struct foo_s *')
+ pytest.raises(VerificationMissing, ffi.sizeof, 'struct foo_s')
+ pytest.raises(VerificationMissing, ffi.offsetof, 'struct foo_s', 'x')
+ pytest.raises(VerificationMissing, ffi.new, 'struct foo_s *')
ffi.verify("""
struct foo_s {
int a, b, x, c, d, e;
@@ -515,7 +515,7 @@ def test_struct_signedness_ignored():
def test_struct_float_vs_int():
if sys.platform == 'win32':
- py.test.skip("XXX fixme: only gives warnings")
+ pytest.skip("XXX fixme: only gives warnings")
ffi = FFI()
for typename in all_signed_integer_types(ffi):
for real in all_float_types:
@@ -566,7 +566,7 @@ def test_struct_array_guess_length():
def test_struct_array_c99_1():
if sys.platform == 'win32':
- py.test.skip("requires C99")
+ pytest.skip("requires C99")
ffi = FFI()
ffi.cdef("struct foo_s { int x; int a[]; };")
ffi.verify("struct foo_s { int x; int a[]; };")
@@ -589,7 +589,7 @@ def test_struct_array_c99_1():
def test_struct_array_c99_2():
if sys.platform == 'win32':
- py.test.skip("requires C99")
+ pytest.skip("requires C99")
ffi = FFI()
ffi.cdef("struct foo_s { int x; int a[]; ...; };")
ffi.verify("struct foo_s { int x, y; int a[]; };")
@@ -644,7 +644,7 @@ def test_struct_with_bitfield_enum():
def test_unsupported_struct_with_bitfield_ellipsis():
ffi = FFI()
- py.test.raises(NotImplementedError, ffi.cdef,
+ pytest.raises(NotImplementedError, ffi.cdef,
"struct foo_s { int a:2, b:3; ...; };")
def test_global_constants():
@@ -691,7 +691,7 @@ def test_global_constants_non_int():
def test_nonfull_enum():
ffi = FFI()
ffi.cdef("enum ee { EE1, EE2, EE3, ... \n \t };")
- py.test.raises(VerificationMissing, ffi.cast, 'enum ee', 'EE2')
+ pytest.raises(VerificationMissing, ffi.cast, 'enum ee', 'EE2')
ffi.verify("enum ee { EE1=10, EE2, EE3=-10, EE4 };")
assert ffi.string(ffi.cast('enum ee', 11)) == "EE2"
assert ffi.string(ffi.cast('enum ee', -10)) == "EE3"
@@ -733,14 +733,14 @@ def test_nonfull_anonymous_enum():
def test_nonfull_enum_syntax2():
ffi = FFI()
ffi.cdef("enum ee { EE1, EE2=\t..., EE3 };")
- py.test.raises(VerificationMissing, ffi.cast, 'enum ee', 'EE1')
+ pytest.raises(VerificationMissing, ffi.cast, 'enum ee', 'EE1')
ffi.verify("enum ee { EE1=10, EE2, EE3=-10, EE4 };")
assert ffi.string(ffi.cast('enum ee', 11)) == 'EE2'
assert ffi.string(ffi.cast('enum ee', -10)) == 'EE3'
#
ffi = FFI()
ffi.cdef("enum ee { EE1, EE2=\t... };")
- py.test.raises(VerificationMissing, ffi.cast, 'enum ee', 'EE1')
+ pytest.raises(VerificationMissing, ffi.cast, 'enum ee', 'EE1')
ffi.verify("enum ee { EE1=10, EE2, EE3=-10, EE4 };")
assert ffi.string(ffi.cast('enum ee', 11)) == 'EE2'
#
@@ -822,7 +822,7 @@ def test_access_array_variable(length=5):
# work with array instances whose length we know. using a pointer
# instead of an array gives the correct effects.
assert repr(lib.somenumber).startswith("<cdata 'int *' 0x")
- py.test.raises(TypeError, len, lib.somenumber)
+ pytest.raises(TypeError, len, lib.somenumber)
else:
assert repr(lib.somenumber).startswith("<cdata 'int[%s]' 0x" % length)
assert len(lib.somenumber) == 5
@@ -978,10 +978,10 @@ def test_varargs():
def test_varargs_exact():
if sys.platform == 'win32':
- py.test.skip("XXX fixme: only gives warnings")
+ pytest.skip("XXX fixme: only gives warnings")
ffi = FFI()
ffi.cdef("int foo(int x, ...);")
- py.test.raises(VerificationError, ffi.verify, """
+ pytest.raises(VerificationError, ffi.verify, """
int foo(long long x, ...) {
return x;
}
@@ -1037,7 +1037,7 @@ def test_autofilled_struct_as_argument_dynamic():
}
static int (*foo)(struct foo_s s) = &foo1;
""")
- e = py.test.raises(NotImplementedError, lib.foo, "?")
+ e = pytest.raises(NotImplementedError, lib.foo, "?")
msg = ("ctype 'struct foo_s' not supported as argument. It is a struct "
'declared with "...;", but the C calling convention may depend on '
"the missing fields; or, it contains anonymous struct/unions. "
@@ -1114,7 +1114,7 @@ def test_enum_as_argument():
int foo_func(enum foo_e e) { return (int)e; }
""")
assert lib.foo_func(lib.BB) == 2
- py.test.raises(TypeError, lib.foo_func, "BB")
+ pytest.raises(TypeError, lib.foo_func, "BB")
def test_enum_as_function_result():
ffi = FFI()
@@ -1172,7 +1172,7 @@ def test_typedef_enum_as_argument():
int foo_func(foo_t e) { return (int)e; }
""")
assert lib.foo_func(lib.BB) == lib.BB == 2
- py.test.raises(TypeError, lib.foo_func, "BB")
+ pytest.raises(TypeError, lib.foo_func, "BB")
def test_typedef_enum_as_function_result():
ffi = FFI()
@@ -1198,9 +1198,9 @@ def test_function_typedef():
def test_opaque_integer_as_function_result():
#import platform
#if platform.machine().startswith('sparc'):
- # py.test.skip('Breaks horribly on sparc (SIGILL + corrupted stack)')
+ # pytest.skip('Breaks horribly on sparc (SIGILL + corrupted stack)')
#elif platform.machine() == 'mips64' and sys.maxsize > 2**32:
- # py.test.skip('Segfaults on mips64el')
+ # pytest.skip('Segfaults on mips64el')
# XXX bad abuse of "struct { ...; }". It only works a bit by chance
# anyway. XXX think about something better :-(
ffi = FFI()
@@ -1252,7 +1252,7 @@ def test_take_and_return_partial_structs():
def test_cannot_name_struct_type():
ffi = FFI()
ffi.cdef("typedef struct { int x; } **sp; void foo(sp);")
- e = py.test.raises(VerificationError, ffi.verify,
+ e = pytest.raises(VerificationError, ffi.verify,
"typedef struct { int x; } **sp; void foo(sp x) { }")
assert 'in argument of foo: unknown type name' in str(e.value)
@@ -1264,7 +1264,7 @@ def test_dont_check_unnamable_fields():
def test_nested_anonymous_struct_exact():
if sys.platform == 'win32':
- py.test.skip("nested anonymous struct/union")
+ pytest.skip("nested anonymous struct/union")
ffi = FFI()
ffi.cdef("""
struct foo_s { struct { int a; char b; }; union { char c, d; }; };
@@ -1286,16 +1286,16 @@ def test_nested_anonymous_struct_exact():
def test_nested_anonymous_struct_exact_error():
if sys.platform == 'win32':
- py.test.skip("nested anonymous struct/union")
+ pytest.skip("nested anonymous struct/union")
ffi = FFI()
ffi.cdef("""
struct foo_s { struct { int a; char b; }; union { char c, d; }; };
""")
- py.test.raises(VerificationError, ffi.verify, """
+ pytest.raises(VerificationError, ffi.verify, """
struct foo_s { struct { int a; short b; }; union { char c, d; }; };
""")
# works fine now
- #py.test.raises(VerificationError, ffi.verify, """
+ #pytest.raises(VerificationError, ffi.verify, """
# struct foo_s { struct { int a; char e, b; }; union { char c, d; }; };
#""")
@@ -1356,7 +1356,7 @@ def test_ffi_union_with_partial_struct_2():
def test_ffi_struct_packed():
if sys.platform == 'win32':
- py.test.skip("needs a GCC extension")
+ pytest.skip("needs a GCC extension")
ffi = FFI()
ffi.cdef("struct foo_s { int b; ...; };")
ffi.verify("""
@@ -1377,7 +1377,7 @@ def test_tmpdir():
assert lib.foo(100) == 142
def test_relative_to():
- py.test.skip("not available")
+ pytest.skip("not available")
import tempfile, os
from testing.udir import udir
tmpdir = tempfile.mkdtemp(dir=str(udir))
@@ -1408,7 +1408,7 @@ def test_bug1():
def test_bool():
if sys.platform == 'win32':
- py.test.skip("_Bool not in MSVC")
+ pytest.skip("_Bool not in MSVC")
ffi = FFI()
ffi.cdef("struct foo_s { _Bool x; };"
"_Bool foo(_Bool); static _Bool (*foop)(_Bool);")
@@ -1432,13 +1432,13 @@ def test_bool():
assert lib.foop(1) is False
assert lib.foop(True) is False
assert lib.foop(0) is True
- py.test.raises(OverflowError, lib.foop, 42)
- py.test.raises(TypeError, lib.foop, 0.0)
+ pytest.raises(OverflowError, lib.foop, 42)
+ pytest.raises(TypeError, lib.foop, 0.0)
assert lib.foo(1) is False
assert lib.foo(True) is False
assert lib.foo(0) is True
- py.test.raises(OverflowError, lib.foo, 42)
- py.test.raises(TypeError, lib.foo, 0.0)
+ pytest.raises(OverflowError, lib.foo, 42)
+ pytest.raises(TypeError, lib.foo, 0.0)
assert int(ffi.cast("_Bool", long(1))) == 1
assert int(ffi.cast("_Bool", long(0))) == 0
assert int(ffi.cast("_Bool", long(-1))) == 1
@@ -1459,14 +1459,14 @@ def test_bool():
assert int(ffi.cast("_Bool", f)) == 0
assert f.seen
#
- py.test.raises(TypeError, ffi.cast, "_Bool", [])
+ pytest.raises(TypeError, ffi.cast, "_Bool", [])
def test_bool_on_long_double():
if sys.platform == 'win32':
- py.test.skip("_Bool not in MSVC")
+ pytest.skip("_Bool not in MSVC")
f = 1E-250
if f == 0.0 or f*f != 0.0:
- py.test.skip("unexpected precision")
+ pytest.skip("unexpected precision")
ffi = FFI()
ffi.cdef("long double square(long double f); _Bool opposite(_Bool);")
lib = ffi.verify("long double square(long double f) { return f*f; }\n"
@@ -1475,12 +1475,12 @@ def test_bool_on_long_double():
f2 = lib.square(f)
f3 = lib.square(f * 2.0)
if repr(f2) == repr(f3):
- py.test.skip("long double doesn't have enough precision")
+ pytest.skip("long double doesn't have enough precision")
assert float(f0) == float(f2) == float(f3) == 0.0 # too tiny for 'double'
assert int(ffi.cast("_Bool", f2)) == 1
assert int(ffi.cast("_Bool", f3)) == 1
assert int(ffi.cast("_Bool", f0)) == 0
- py.test.raises(TypeError, lib.opposite, f2)
+ pytest.raises(TypeError, lib.opposite, f2)
def test_cannot_pass_float():
for basetype in ['char', 'short', 'int', 'long', 'long long']:
@@ -1500,7 +1500,7 @@ def test_cannot_pass_float():
p.x = 0.0
assert lib.foo(42) == 0
assert lib.foo(0) == 1
- py.test.raises(TypeError, lib.foo, 0.0)
+ pytest.raises(TypeError, lib.foo, 0.0)
def test_addressof():
ffi = FFI()
@@ -1522,19 +1522,19 @@ def test_addressof():
p = ffi.new("struct foo_s *")
p.point.x = 16
p.point.y = 9
- py.test.raises(TypeError, lib.sum_coord, p.point)
+ pytest.raises(TypeError, lib.sum_coord, p.point)
res = lib.sum_coord(ffi.addressof(p.point))
assert res.x == 25
assert res.y == 7
res2 = lib.sum_coord(ffi.addressof(res))
assert res2.x == 32
assert res2.y == 18
- py.test.raises(TypeError, lib.sum_coord, res2)
+ pytest.raises(TypeError, lib.sum_coord, res2)
def test_callback_in_thread():
- py.test.xfail("adapt or remove")
+ pytest.xfail("adapt or remove")
if sys.platform == 'win32':
- py.test.skip("pthread only")
+ pytest.skip("pthread only")
import os, subprocess, imp
arg = os.path.join(os.path.dirname(__file__), 'callback_in_thread.py')
g = subprocess.Popen([sys.executable, arg,
@@ -1543,7 +1543,7 @@ def test_callback_in_thread():
assert result == 0
def test_keepalive_lib():
- py.test.xfail("adapt or remove")
+ pytest.xfail("adapt or remove")
ffi = FFI()
ffi.cdef("int foobar(void);")
lib = ffi.verify("int foobar(void) { return 42; }")
@@ -1557,7 +1557,7 @@ def test_keepalive_lib():
assert func() == 42
def test_keepalive_ffi():
- py.test.xfail("adapt or remove")
+ pytest.xfail("adapt or remove")
ffi = FFI()
ffi.cdef("int foobar(void);")
lib = ffi.verify("int foobar(void) { return 42; }")
@@ -1572,7 +1572,7 @@ def test_keepalive_ffi():
def test_FILE_stored_in_stdout():
if not sys.platform.startswith('linux') or is_musl:
- py.test.skip("likely, we cannot assign to stdout")
+ pytest.skip("likely, we cannot assign to stdout")
ffi = FFI()
ffi.cdef("int printf(const char *, ...); FILE *setstdout(FILE *);")
lib = ffi.verify("""
@@ -1642,11 +1642,11 @@ def test_global_array_with_dotdotdot_length():
assert repr(lib.fooarray).startswith("<cdata 'int[50]'")
def test_bad_global_array_with_dotdotdot_length():
- py.test.xfail("was detected only because 23 bytes cannot be divided by 4; "
+ pytest.xfail("was detected only because 23 bytes cannot be divided by 4; "
"redo more generally")
ffi = FFI()
ffi.cdef("extern int fooarray[...];")
- py.test.raises(VerificationError, ffi.verify, "char fooarray[23];")
+ pytest.raises(VerificationError, ffi.verify, "char fooarray[23];")
def test_struct_containing_struct():
ffi = FFI()
@@ -1660,7 +1660,7 @@ def test_struct_containing_struct():
def test_struct_returned_by_func():
ffi = FFI()
ffi.cdef("typedef ... foo_t; foo_t myfunc(void);")
- e = py.test.raises(TypeError, ffi.verify,
+ e = pytest.raises(TypeError, ffi.verify,
"typedef struct { int x; } foo_t; "
"foo_t myfunc(void) { foo_t x = { 42 }; return x; }")
assert str(e.value) == (
@@ -1849,15 +1849,15 @@ def test_passing_string_or_NULL():
assert lib.seeme1(ffi.NULL) == 1
assert lib.seeme2([42, 43]) == 0
assert lib.seeme2(ffi.NULL) == 1
- py.test.raises(TypeError, lib.seeme1, None)
- py.test.raises(TypeError, lib.seeme2, None)
- py.test.raises(TypeError, lib.seeme1, 0.0)
- py.test.raises(TypeError, lib.seeme2, 0.0)
- py.test.raises(TypeError, lib.seeme1, 0)
- py.test.raises(TypeError, lib.seeme2, 0)
+ pytest.raises(TypeError, lib.seeme1, None)
+ pytest.raises(TypeError, lib.seeme2, None)
+ pytest.raises(TypeError, lib.seeme1, 0.0)
+ pytest.raises(TypeError, lib.seeme2, 0.0)
+ pytest.raises(TypeError, lib.seeme1, 0)
+ pytest.raises(TypeError, lib.seeme2, 0)
zeroL = 99999999999999999999
zeroL -= 99999999999999999999
- py.test.raises(TypeError, lib.seeme2, zeroL)
+ pytest.raises(TypeError, lib.seeme2, zeroL)
def test_typeof_function():
ffi = FFI()
@@ -2078,7 +2078,7 @@ def test_errno_working_even_with_pypys_jit():
def test_getlasterror_working_even_with_pypys_jit():
if sys.platform != 'win32':
- py.test.skip("win32-only test")
+ pytest.skip("win32-only test")
ffi = FFI()
ffi.cdef("void SetLastError(DWORD);")
lib = ffi.dlopen("Kernel32.dll")
@@ -2091,7 +2091,7 @@ def test_getlasterror_working_even_with_pypys_jit():
def test_verify_dlopen_flags():
if not hasattr(sys, 'setdlopenflags'):
- py.test.skip("requires sys.setdlopenflags()")
+ pytest.skip("requires sys.setdlopenflags()")
# Careful with RTLD_GLOBAL. If by chance the FFI is not deleted
# promptly, like on PyPy, then other tests may see the same
# exported symbols as well. So we must not export a simple name
@@ -2125,19 +2125,19 @@ def test_consider_not_implemented_function_type():
bazptr = ffi.cast("bazfunc_t", 123)
barptr = ffi.cast("barfunc_t", 123)
# assert did not crash so far
- e = py.test.raises(NotImplementedError, fooptr, ffi.new("Data *"))
+ e = pytest.raises(NotImplementedError, fooptr, ffi.new("Data *"))
assert str(e.value) == (
"ctype 'Data' not supported as argument by libffi. Unions are only "
"supported as argument if the function is 'API mode' and "
"non-variadic (i.e. declared inside ffibuilder.cdef()+"
"ffibuilder.set_source() and not taking a final '...' argument)")
- e = py.test.raises(NotImplementedError, bazptr)
+ e = pytest.raises(NotImplementedError, bazptr)
assert str(e.value) == (
"ctype 'Data' not supported as return value by libffi. Unions are "
"only supported as return value if the function is 'API mode' and "
"non-variadic (i.e. declared inside ffibuilder.cdef()+"
"ffibuilder.set_source() and not taking a final '...' argument)")
- e = py.test.raises(NotImplementedError, barptr)
+ e = pytest.raises(NotImplementedError, barptr)
assert str(e.value) == (
"ctype 'MyStr' not supported as return value. It is a struct with "
"bit fields, which libffi does not support. Such structs are only "
@@ -2154,9 +2154,9 @@ def test_verify_extra_arguments():
def test_implicit_unicode_on_windows():
from cffi import FFIError
if sys.platform != 'win32':
- py.test.skip("win32-only test")
+ pytest.skip("win32-only test")
ffi = FFI()
- e = py.test.raises(FFIError, ffi.cdef, "int foo(LPTSTR);")
+ e = pytest.raises(FFIError, ffi.cdef, "int foo(LPTSTR);")
assert str(e.value) == ("The Windows type 'LPTSTR' is only available after"
" you call ffi.set_unicode()")
for with_unicode in [True, False]:
@@ -2219,16 +2219,16 @@ def test_some_integer_type_for_issue73():
def test_unsupported_some_primitive_types():
ffi = FFI()
- py.test.raises((FFIError, # with pycparser <= 2.17
+ pytest.raises((FFIError, # with pycparser <= 2.17
CDefError), # with pycparser >= 2.18
ffi.cdef, """typedef void... foo_t;""")
#
ffi.cdef("typedef int... foo_t;")
- py.test.raises(VerificationError, ffi.verify, "typedef float foo_t;")
+ pytest.raises(VerificationError, ffi.verify, "typedef float foo_t;")
def test_windows_dllimport_data():
if sys.platform != 'win32':
- py.test.skip("Windows only")
+ pytest.skip("Windows only")
from testing.udir import udir
tmpfile = udir.join('dllimport_data.c')
tmpfile.write('int my_value = 42;\n')
@@ -2278,7 +2278,7 @@ def test_share_FILE():
def test_win_common_types():
if sys.platform != 'win32':
- py.test.skip("Windows only")
+ pytest.skip("Windows only")
ffi = FFI()
ffi.set_unicode(True)
ffi.verify("")
@@ -2292,11 +2292,11 @@ def test_win_common_types():
def _only_test_on_linux_intel():
if not sys.platform.startswith('linux'):
- py.test.skip('only running the memory-intensive test on Linux')
+ pytest.skip('only running the memory-intensive test on Linux')
import platform
machine = platform.machine()
if 'x86' not in machine and 'x64' not in machine:
- py.test.skip('only running the memory-intensive test on x86/x64')
+ pytest.skip('only running the memory-intensive test on x86/x64')
def test_ffi_gc_size_arg():
_only_test_on_linux_intel()
@@ -2320,7 +2320,7 @@ def test_ffi_gc_size_arg_2():
# and I found no obvious way to prevent that. So for now, this test
# is skipped on CPython, where it eats all the memory.
if '__pypy__' not in sys.builtin_module_names:
- py.test.skip("find a way to tweak the cyclic GC of CPython")
+ pytest.skip("find a way to tweak the cyclic GC of CPython")
_only_test_on_linux_intel()
ffi = FFI()
ffi.cdef("void *malloc(size_t); void free(void *);")
@@ -2343,7 +2343,7 @@ def test_ffi_gc_size_arg_2():
def test_ffi_new_with_cycles():
# still another variant, with ffi.new()
if '__pypy__' not in sys.builtin_module_names:
- py.test.skip("find a way to tweak the cyclic GC of CPython")
+ pytest.skip("find a way to tweak the cyclic GC of CPython")
ffi = FFI()
ffi.cdef("")
lib = ffi.verify("")