Debian Codegraph @

debian/patches/pycparser-3

raw
1 From: Eli Bendersky <[email protected]>
2 Date: Sat, 24 Jan 2026 17:54:58 -0800
3 Subject: Make test_parsing more resilient to changes in pycparser (#224)
4
5 * Make test_parsing more resilient to changes in pycparser
6
7 Several tests expect precise error messages from pycparser, which pycparser
8 doesn't guarantee. While testing CFFI with pycparser 3.0, some tests needed
9 to be made more resilient. I've used the .startswith() approach already used
10 in this file, instead of exact string matching.
11
12 Ref #223
13
14 * Loosen error message assertion even more
15
16 Origin: upstream, https://github.com/python-cffi/cffi/commit/c36c02fa6f4f1d12a9cead81861c6f42af47da22
17 ---
18 testing/cffi0/test_parsing.py | 18 +++++++++---------
19 1 file changed, 9 insertions(+), 9 deletions(-)
20
21 diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
22 index f10b989..7009e34 100644
23 --- a/testing/cffi0/test_parsing.py
24 +++ b/testing/cffi0/test_parsing.py
25 @@ -197,7 +197,7 @@ def test_dont_remove_comment_in_line_directives():
26
27 some syntax error here
28 """)
29 - assert str(e.value) == "parse error\nbaz.c:9:14: before: syntax"
30 + assert str(e.value).startswith("parse error\nbaz.c:9:")
31 #
32 e = pytest.raises(CDefError, ffi.cdef, """
33 #line 7 "foo//bar.c"
34 @@ -205,21 +205,21 @@ def test_dont_remove_comment_in_line_directives():
35 some syntax error here
36 """)
37 #
38 - assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
39 + assert str(e.value).startswith("parse error\nfoo//bar.c:8:")
40 ffi = FFI(backend=FakeBackend())
41 e = pytest.raises(CDefError, ffi.cdef, """
42 \t # \t 8 \t "baz.c" \t
43
44 some syntax error here
45 """)
46 - assert str(e.value) == "parse error\nbaz.c:9:14: before: syntax"
47 + assert str(e.value).startswith("parse error\nbaz.c:9:")
48 #
49 e = pytest.raises(CDefError, ffi.cdef, """
50 # 7 "foo//bar.c"
51
52 some syntax error here
53 """)
54 - assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
55 + assert str(e.value).startswith("parse error\nfoo//bar.c:8:")
56
57 def test_multiple_line_directives():
58 ffi = FFI(backend=FakeBackend())
59 @@ -233,7 +233,7 @@ def test_multiple_line_directives():
60 #line 8 "yadda.c"
61 extern int zz;
62 """)
63 - assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
64 + assert str(e.value).startswith("parse error\nbaz.c:7:")
65 #
66 e = pytest.raises(CDefError, ffi.cdef,
67 """ # 5 "foo.c"
68 @@ -245,7 +245,7 @@ def test_multiple_line_directives():
69 # 8 "yadda.c"
70 extern int zz;
71 """)
72 - assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
73 + assert str(e.value).startswith("parse error\nbaz.c:7:")
74
75 def test_commented_line_directive():
76 ffi = FFI(backend=FakeBackend())
77 @@ -262,7 +262,7 @@ def test_commented_line_directive():
78 some syntax error
79 """)
80 #
81 - assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
82 + assert str(e.value).startswith("parse error\nbar.c:9:")
83 e = pytest.raises(CDefError, ffi.cdef, """
84 /*
85 # 5 "foo.c"
86 @@ -275,7 +275,7 @@ def test_commented_line_directive():
87 */
88 some syntax error
89 """)
90 - assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
91 + assert str(e.value).startswith("parse error\nbar.c:9:")
92
93 def test_line_continuation_in_defines():
94 ffi = FFI(backend=FakeBackend())
95 @@ -365,7 +365,7 @@ def test_unknown_name():
96 e = pytest.raises(CDefError, ffi.cast, "foobarbazunknown*", 0)
97 assert str(e.value).startswith('cannot parse "foobarbazunknown*"')
98 e = pytest.raises(CDefError, ffi.cast, "int(*)(foobarbazunknown)", 0)
99 - assert str(e.value).startswith('cannot parse "int(*)(foobarbazunknown)"')
100 + assert 'foobarbazunknown' in str(e.value)
101
102 def test_redefine_common_type():
103 prefix = "" if sys.version_info < (3,) else "b"