summaryrefslogtreecommitdiff
path: root/testing/cffi1/test_ffi_obj.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/cffi1/test_ffi_obj.py')
-rw-r--r--testing/cffi1/test_ffi_obj.py48
1 files changed, 24 insertions, 24 deletions
diff --git a/testing/cffi1/test_ffi_obj.py b/testing/cffi1/test_ffi_obj.py
index 0d29290..9085fb8 100644
--- a/testing/cffi1/test_ffi_obj.py
+++ b/testing/cffi1/test_ffi_obj.py
@@ -1,4 +1,4 @@
-import py, sys
+import sys
import pytest
import _cffi_backend as _cffi1_backend
@@ -21,7 +21,7 @@ def test_ffi_subclass():
assert type(foo) is foo.__class__ is FOO
def test_ffi_no_argument():
- py.test.raises(TypeError, _cffi1_backend.FFI, 42)
+ pytest.raises(TypeError, _cffi1_backend.FFI, 42)
def test_ffi_cache_type():
ffi = _cffi1_backend.FFI()
@@ -68,7 +68,7 @@ def test_ffi_cache_type_globally():
def test_ffi_invalid():
ffi = _cffi1_backend.FFI()
# array of 10 times an "int[]" is invalid
- py.test.raises(ValueError, ffi.typeof, "int[10][]")
+ pytest.raises(ValueError, ffi.typeof, "int[10][]")
def test_ffi_docstrings():
# check that all methods of the FFI class have a docstring.
@@ -117,7 +117,7 @@ def test_ffi_alignof():
def test_ffi_sizeof():
ffi = _cffi1_backend.FFI()
assert ffi.sizeof("int") == 4
- py.test.raises(ffi.error, ffi.sizeof, "int[]")
+ pytest.raises(ffi.error, ffi.sizeof, "int[]")
assert ffi.sizeof("int[41]") == 41 * 4
assert ffi.sizeof(ffi.new("int[41]")) == 41 * 4
assert ffi.sizeof(ffi.new("int[]", 41)) == 41 * 4
@@ -162,7 +162,7 @@ def test_ffi_callback_onerror():
assert isinstance(val, TypeError)
assert tb.tb_frame.f_code.co_name == "fn2"
#
- py.test.raises(TypeError, ffi.callback, "int(int)",
+ pytest.raises(TypeError, ffi.callback, "int(int)",
lambda x: x, onerror=42) # <- not callable
def test_ffi_getctype():
@@ -208,28 +208,28 @@ def test_ffi_cast():
ffi = _cffi1_backend.FFI()
assert ffi.cast("int(*)(int)", 0) == ffi.NULL
ffi.callback("int(int)") # side-effect of registering this string
- py.test.raises(ffi.error, ffi.cast, "int(int)", 0)
+ pytest.raises(ffi.error, ffi.cast, "int(int)", 0)
def test_ffi_invalid_type():
ffi = _cffi1_backend.FFI()
- e = py.test.raises(ffi.error, ffi.cast, "", 0)
+ e = pytest.raises(ffi.error, ffi.cast, "", 0)
assert str(e.value) == ("identifier expected\n"
"\n"
"^")
- e = py.test.raises(ffi.error, ffi.cast, "struct struct", 0)
+ e = pytest.raises(ffi.error, ffi.cast, "struct struct", 0)
assert str(e.value) == ("struct or union name expected\n"
"struct struct\n"
" ^")
- e = py.test.raises(ffi.error, ffi.cast, "struct never_heard_of_s", 0)
+ e = pytest.raises(ffi.error, ffi.cast, "struct never_heard_of_s", 0)
assert str(e.value) == ("undefined struct/union name\n"
"struct never_heard_of_s\n"
" ^")
- e = py.test.raises(ffi.error, ffi.cast, "\t\n\x01\x1f~\x7f\x80\xff", 0)
+ e = pytest.raises(ffi.error, ffi.cast, "\t\n\x01\x1f~\x7f\x80\xff", 0)
marks = "?" if sys.version_info < (3,) else "??"
assert str(e.value) == ("identifier expected\n"
" ??~?%s%s\n"
" ^" % (marks, marks))
- e = py.test.raises(ffi.error, ffi.cast, "X" * 600, 0)
+ e = pytest.raises(ffi.error, ffi.cast, "X" * 600, 0)
assert str(e.value) == ("undefined type name")
def test_ffi_buffer():
@@ -248,7 +248,7 @@ def test_ffi_from_buffer():
assert len(c) == 8
ffi.cast("unsigned short *", c)[1] += 500
assert list(a) == [10000, 20500, 30000, 40000]
- py.test.raises(TypeError, ffi.from_buffer, a, True)
+ pytest.raises(TypeError, ffi.from_buffer, a, True)
assert c == ffi.from_buffer("char[]", a, True)
assert c == ffi.from_buffer(a, require_writable=True)
#
@@ -265,9 +265,9 @@ def test_ffi_from_buffer():
assert p[2] == b"c"
#
assert p == ffi.from_buffer(b"abcd", require_writable=False)
- py.test.raises((TypeError, BufferError), ffi.from_buffer,
+ pytest.raises((TypeError, BufferError), ffi.from_buffer,
"char[]", b"abcd", True)
- py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd",
+ pytest.raises((TypeError, BufferError), ffi.from_buffer, b"abcd",
require_writable=True)
def test_memmove():
@@ -318,7 +318,7 @@ def test_memmove_readonly_readwrite():
assert list(p) == [ord("a"), ord("b"), ord("c"), 0, 0]
ffi.memmove(p, bytearray(b"ABCDE"), 2)
assert list(p) == [ord("A"), ord("B"), ord("c"), 0, 0]
- py.test.raises((TypeError, BufferError), ffi.memmove, b"abcde", p, 3)
+ pytest.raises((TypeError, BufferError), ffi.memmove, b"abcde", p, 3)
ba = bytearray(b"xxxxx")
ffi.memmove(dest=ba, src=p, n=3)
assert ba == bytearray(b"ABcxx")
@@ -332,7 +332,7 @@ def test_ffi_types():
def test_ffi_getwinerror():
if sys.platform != "win32":
- py.test.skip("for windows")
+ pytest.skip("for windows")
ffi = _cffi1_backend.FFI()
n = (1 << 29) + 42
code, message = ffi.getwinerror(code=n)
@@ -407,29 +407,29 @@ def test_ffi_new_allocator_3():
def test_ffi_new_allocator_4():
ffi = _cffi1_backend.FFI()
- py.test.raises(TypeError, ffi.new_allocator, free=lambda x: None)
+ pytest.raises(TypeError, ffi.new_allocator, free=lambda x: None)
#
def myalloc2(size):
raise LookupError
alloc2 = ffi.new_allocator(myalloc2)
- py.test.raises(LookupError, alloc2, "int[5]")
+ pytest.raises(LookupError, alloc2, "int[5]")
#
def myalloc3(size):
return 42
alloc3 = ffi.new_allocator(myalloc3)
- e = py.test.raises(TypeError, alloc3, "int[5]")
+ e = pytest.raises(TypeError, alloc3, "int[5]")
assert str(e.value) == "alloc() must return a cdata object (got int)"
#
def myalloc4(size):
return ffi.cast("int", 42)
alloc4 = ffi.new_allocator(myalloc4)
- e = py.test.raises(TypeError, alloc4, "int[5]")
+ e = pytest.raises(TypeError, alloc4, "int[5]")
assert str(e.value) == "alloc() must return a cdata pointer, not 'int'"
#
def myalloc5(size):
return ffi.NULL
alloc5 = ffi.new_allocator(myalloc5)
- py.test.raises(MemoryError, alloc5, "int[5]")
+ pytest.raises(MemoryError, alloc5, "int[5]")
def test_bool_issue228():
ffi = _cffi1_backend.FFI()
@@ -497,7 +497,7 @@ def test_init_once_failure():
ffi = _cffi1_backend.FFI()
seen = []
for i in range(5):
- py.test.raises(ValueError, ffi.init_once, do_init, "tag")
+ pytest.raises(ValueError, ffi.init_once, do_init, "tag")
assert seen == [1] * (i + 1)
def test_init_once_multithread_failure():
@@ -515,7 +515,7 @@ def test_init_once_multithread_failure():
seen = []
for i in range(3):
def f():
- py.test.raises(ValueError, ffi.init_once, do_init, "tag")
+ pytest.raises(ValueError, ffi.init_once, do_init, "tag")
thread.start_new_thread(f, ())
i = 0
while len(seen) < 6:
@@ -533,4 +533,4 @@ def test_unpack():
def test_negative_array_size():
ffi = _cffi1_backend.FFI()
- py.test.raises(ffi.error, ffi.cast, "int[-5]", 0)
+ pytest.raises(ffi.error, ffi.cast, "int[-5]", 0)