summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2017-05-09 18:07:19 +0200
committerArmin Rigo <arigo@tunes.org>2017-05-09 18:07:19 +0200
commita780b6772eeced3b5b57e313a5b9cf394f722f9e (patch)
tree4de3378c8d0bbf6d09db4f3aab898e8a65c6b58a /testing
parentb274305dc3a28495b12ac25430fbad9d66ba40d0 (diff)
downloadcffi-a780b6772eeced3b5b57e313a5b9cf394f722f9e.tar.gz
Try to systematically include the line number
Diffstat (limited to 'testing')
-rw-r--r--testing/cffi0/test_parsing.py14
1 files changed, 11 insertions, 3 deletions
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) == (
+ "<cdef source string>: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) == ("<cdef source string>: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) == ('<cdef source string>:1: unexpected <FuncDef>: '
+ 'this construct is valid C but not valid in cdef()')