From a780b6772eeced3b5b57e313a5b9cf394f722f9e Mon Sep 17 00:00:00 2001 From: Armin Rigo Date: Tue, 9 May 2017 18:07:19 +0200 Subject: Try to systematically include the line number --- testing/cffi0/test_parsing.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'testing') diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py index 5481f56..ad318ad 100644 --- a/testing/cffi0/test_parsing.py +++ b/testing/cffi0/test_parsing.py @@ -228,8 +228,9 @@ 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(...);") - assert str(e.value) == \ - "foo: a function with only '(...)' as argument is not correct C" + assert str(e.value) == ( + ":1: foo: a function with only '(...)' " + "as argument is not correct C") def test_parse_error(): ffi = FFI() @@ -291,7 +292,8 @@ def test_bool(): def test_unknown_argument_type(): ffi = FFI() e = py.test.raises(CDefError, ffi.cdef, "void f(foobarbazzz);") - assert str(e.value) == ("f arg 1: unknown type 'foobarbazzz' (if you meant" + assert str(e.value) == (":1: f arg 1:" + " unknown type 'foobarbazzz' (if you meant" " to use the old C syntax of giving untyped" " arguments, it is not supported)") @@ -449,3 +451,9 @@ def test_extern_python_group(): ffi._parser._declarations['extern_python foobar'] != ffi._parser._declarations['function bok'] == ffi._parser._declarations['extern_python bzrrr']) + +def test_error_invalid_syntax_for_cdef(): + ffi = FFI() + e = py.test.raises(CDefError, ffi.cdef, 'void foo(void) {}') + assert str(e.value) == (':1: unexpected : ' + 'this construct is valid C but not valid in cdef()') -- cgit v1.2.1