File: pycparser-3

package info (click to toggle)
python-cffi 2.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,816 kB
  • sloc: python: 28,459; ansic: 15,272; asm: 116; makefile: 97; sh: 14
file content (103 lines) | stat: -rw-r--r-- 3,914 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
From: Eli Bendersky <eliben@gmail.com>
Date: Sat, 24 Jan 2026 17:54:58 -0800
Subject: Make test_parsing more resilient to changes in pycparser (#224)

* Make test_parsing more resilient to changes in pycparser

Several tests expect precise error messages from pycparser, which pycparser
doesn't guarantee. While testing CFFI with pycparser 3.0, some tests needed
to be made more resilient. I've used the .startswith() approach already used
in this file, instead of exact string matching.

Ref #223

* Loosen error message assertion even more

Origin: upstream, https://github.com/python-cffi/cffi/commit/c36c02fa6f4f1d12a9cead81861c6f42af47da22
---
 testing/cffi0/test_parsing.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
index f10b989..7009e34 100644
--- a/testing/cffi0/test_parsing.py
+++ b/testing/cffi0/test_parsing.py
@@ -197,7 +197,7 @@ def test_dont_remove_comment_in_line_directives():
 
         some syntax error here
     """)
-    assert str(e.value) == "parse error\nbaz.c:9:14: before: syntax"
+    assert str(e.value).startswith("parse error\nbaz.c:9:")
     #
     e = pytest.raises(CDefError, ffi.cdef, """
         #line 7 "foo//bar.c"
@@ -205,21 +205,21 @@ def test_dont_remove_comment_in_line_directives():
         some syntax error here
     """)
     #
-    assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
+    assert str(e.value).startswith("parse error\nfoo//bar.c:8:")
     ffi = FFI(backend=FakeBackend())
     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"
+    assert str(e.value).startswith("parse error\nbaz.c:9:")
     #
     e = pytest.raises(CDefError, ffi.cdef, """
         # 7 "foo//bar.c"
 
         some syntax error here
     """)
-    assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
+    assert str(e.value).startswith("parse error\nfoo//bar.c:8:")
 
 def test_multiple_line_directives():
     ffi = FFI(backend=FakeBackend())
@@ -233,7 +233,7 @@ def test_multiple_line_directives():
         #line 8 "yadda.c"
         extern int zz;
     """)
-    assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
+    assert str(e.value).startswith("parse error\nbaz.c:7:")
     #
     e = pytest.raises(CDefError, ffi.cdef,
     """ # 5 "foo.c"
@@ -245,7 +245,7 @@ def test_multiple_line_directives():
         # 8 "yadda.c"
         extern int zz;
     """)
-    assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
+    assert str(e.value).startswith("parse error\nbaz.c:7:")
 
 def test_commented_line_directive():
     ffi = FFI(backend=FakeBackend())
@@ -262,7 +262,7 @@ def test_commented_line_directive():
         some syntax error
     """)
     #
-    assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
+    assert str(e.value).startswith("parse error\nbar.c:9:")
     e = pytest.raises(CDefError, ffi.cdef, """
         /*
         # 5 "foo.c"
@@ -275,7 +275,7 @@ def test_commented_line_directive():
         */
         some syntax error
     """)
-    assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
+    assert str(e.value).startswith("parse error\nbar.c:9:")
 
 def test_line_continuation_in_defines():
     ffi = FFI(backend=FakeBackend())
@@ -365,7 +365,7 @@ def test_unknown_name():
     e = pytest.raises(CDefError, ffi.cast, "foobarbazunknown*", 0)
     assert str(e.value).startswith('cannot parse "foobarbazunknown*"')
     e = pytest.raises(CDefError, ffi.cast, "int(*)(foobarbazunknown)", 0)
-    assert str(e.value).startswith('cannot parse "int(*)(foobarbazunknown)"')
+    assert 'foobarbazunknown' in str(e.value)
 
 def test_redefine_common_type():
     prefix = "" if sys.version_info < (3,) else "b"