diff options
Diffstat (limited to 'testing/cffi0/test_parsing.py')
-rw-r--r-- | testing/cffi0/test_parsing.py | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py index 5d93a8d..af6293e 100644 --- a/testing/cffi0/test_parsing.py +++ b/testing/cffi0/test_parsing.py @@ -1,4 +1,5 @@ -import py, sys, re +import sys, re +import pytest from cffi import FFI, FFIError, CDefError, VerificationError from .backend_tests import needs_dlopen_none from testing.support import is_musl @@ -191,14 +192,14 @@ def test_remove_line_continuation_comments(): def test_dont_remove_comment_in_line_directives(): ffi = FFI(backend=FakeBackend()) - e = py.test.raises(CDefError, ffi.cdef, """ + e = pytest.raises(CDefError, ffi.cdef, """ \t # \t line \t 8 \t "baz.c" \t some syntax error here """) assert str(e.value) == "parse error\nbaz.c:9:14: before: syntax" # - e = py.test.raises(CDefError, ffi.cdef, """ + e = pytest.raises(CDefError, ffi.cdef, """ #line 7 "foo//bar.c" some syntax error here @@ -206,14 +207,14 @@ def test_dont_remove_comment_in_line_directives(): # assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax" ffi = FFI(backend=FakeBackend()) - e = py.test.raises(CDefError, ffi.cdef, """ + e = pytest.raises(CDefError, ffi.cdef, """ \t # \t 8 \t "baz.c" \t some syntax error here """) assert str(e.value) == "parse error\nbaz.c:9:14: before: syntax" # - e = py.test.raises(CDefError, ffi.cdef, """ + e = pytest.raises(CDefError, ffi.cdef, """ # 7 "foo//bar.c" some syntax error here @@ -222,7 +223,7 @@ def test_dont_remove_comment_in_line_directives(): def test_multiple_line_directives(): ffi = FFI(backend=FakeBackend()) - e = py.test.raises(CDefError, ffi.cdef, + e = pytest.raises(CDefError, ffi.cdef, """ #line 5 "foo.c" extern int xx; #line 6 "bar.c" @@ -234,7 +235,7 @@ def test_multiple_line_directives(): """) assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax" # - e = py.test.raises(CDefError, ffi.cdef, + e = pytest.raises(CDefError, ffi.cdef, """ # 5 "foo.c" extern int xx; # 6 "bar.c" @@ -248,7 +249,7 @@ def test_multiple_line_directives(): def test_commented_line_directive(): ffi = FFI(backend=FakeBackend()) - e = py.test.raises(CDefError, ffi.cdef, """ + e = pytest.raises(CDefError, ffi.cdef, """ /* #line 5 "foo.c" */ @@ -262,7 +263,7 @@ def test_commented_line_directive(): """) # assert str(e.value) == "parse error\nbar.c:9:14: before: syntax" - e = py.test.raises(CDefError, ffi.cdef, """ + e = pytest.raises(CDefError, ffi.cdef, """ /* # 5 "foo.c" */ @@ -290,7 +291,7 @@ def test_line_continuation_in_defines(): def test_define_not_supported_for_now(): ffi = FFI(backend=FakeBackend()) - e = py.test.raises(CDefError, ffi.cdef, '#define FOO "blah"') + e = pytest.raises(CDefError, ffi.cdef, '#define FOO "blah"') assert str(e.value) == ( 'only supports one of the following syntax:\n' ' #define FOO ... (literally dot-dot-dot)\n' @@ -310,7 +311,7 @@ def test_unnamed_struct(): type_bar = ffi._parser.parse_type("bar_p").totype assert repr(type_foo) == "<foo_t>" assert repr(type_bar) == "<struct $1>" - py.test.raises(VerificationError, type_bar.get_c_name) + pytest.raises(VerificationError, type_bar.get_c_name) assert type_foo.get_c_name() == "foo_t" def test_override(): @@ -318,7 +319,7 @@ def test_override(): needs_dlopen_none() C = ffi.dlopen(None) ffi.cdef("int foo(void);") - py.test.raises(FFIError, ffi.cdef, "long foo(void);") + pytest.raises(FFIError, ffi.cdef, "long foo(void);") assert C.foo.BType == '<func (), <int>, False>' ffi.cdef("long foo(void);", override=True) assert C.foo.BType == '<func (), <long>, False>' @@ -326,23 +327,23 @@ def test_override(): def test_cannot_have_only_variadic_part(): # this checks that we get a sensible error if we try "int foo(...);" ffi = FFI() - e = py.test.raises(CDefError, ffi.cdef, "int foo(...);") + e = pytest.raises(CDefError, ffi.cdef, "int foo(...);") assert str(e.value) == ( "<cdef source string>:1: foo: a function with only '(...)' " "as argument is not correct C") def test_parse_error(): ffi = FFI() - e = py.test.raises(CDefError, ffi.cdef, " x y z ") + e = pytest.raises(CDefError, ffi.cdef, " x y z ") assert str(e.value).startswith( 'cannot parse "x y z"\n<cdef source string>:1:') - e = py.test.raises(CDefError, ffi.cdef, "\n\n\n x y z ") + e = pytest.raises(CDefError, ffi.cdef, "\n\n\n x y z ") assert str(e.value).startswith( 'cannot parse "x y z"\n<cdef source string>:4:') def test_error_custom_lineno(): ffi = FFI() - e = py.test.raises(CDefError, ffi.cdef, """ + e = pytest.raises(CDefError, ffi.cdef, """ # 42 "foobar" a b c d @@ -351,7 +352,7 @@ def test_error_custom_lineno(): def test_cannot_declare_enum_later(): ffi = FFI() - e = py.test.raises(NotImplementedError, ffi.cdef, + e = pytest.raises(NotImplementedError, ffi.cdef, "typedef enum foo_e foo_t; enum foo_e { AA, BB };") assert str(e.value) == ( "enum foo_e: the '{}' declaration should appear on the " @@ -359,11 +360,11 @@ def test_cannot_declare_enum_later(): def test_unknown_name(): ffi = FFI() - e = py.test.raises(CDefError, ffi.cast, "foobarbazunknown", 0) + e = pytest.raises(CDefError, ffi.cast, "foobarbazunknown", 0) assert str(e.value) == "unknown identifier 'foobarbazunknown'" - e = py.test.raises(CDefError, ffi.cast, "foobarbazunknown*", 0) + e = pytest.raises(CDefError, ffi.cast, "foobarbazunknown*", 0) assert str(e.value).startswith('cannot parse "foobarbazunknown*"') - e = py.test.raises(CDefError, ffi.cast, "int(*)(foobarbazunknown)", 0) + e = pytest.raises(CDefError, ffi.cast, "int(*)(foobarbazunknown)", 0) assert str(e.value).startswith('cannot parse "int(*)(foobarbazunknown)"') def test_redefine_common_type(): @@ -390,7 +391,7 @@ def test_bool(): def test_unknown_argument_type(): ffi = FFI() - e = py.test.raises(CDefError, ffi.cdef, "void f(foobarbazzz);") + e = pytest.raises(CDefError, ffi.cdef, "void f(foobarbazzz);") assert str(e.value) == ("<cdef source string>:1: f arg 1:" " unknown type 'foobarbazzz' (if you meant" " to use the old C syntax of giving untyped" @@ -405,7 +406,7 @@ def test_void_renamed_as_only_arg(): def test_WPARAM_on_windows(): if sys.platform != 'win32': - py.test.skip("Only for Windows") + pytest.skip("Only for Windows") ffi = FFI() ffi.cdef("void f(WPARAM);") # @@ -572,7 +573,7 @@ def test_extern_python_group(): def test_error_invalid_syntax_for_cdef(): ffi = FFI() - e = py.test.raises(CDefError, ffi.cdef, 'void foo(void) {}') + e = pytest.raises(CDefError, ffi.cdef, 'void foo(void) {}') assert str(e.value) == ('<cdef source string>:1: unexpected <FuncDef>: ' 'this construct is valid C but not valid in cdef()') |