Skip to content

Commit 96c6763

Browse files
authored
test_builtin_casters.py test_string_view: Python 2 c++17, c++2a compatibility. (#2314)
Tested with 2.7.18rc1, built with Py_UNICODE_SIZE 4. Change also tested with Python 3.8.
1 parent c4fd1fd commit 96c6763

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tests/test_builtin_casters.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,24 +132,24 @@ def test_string_view(capture):
132132
"""Tests support for C++17 string_view arguments and return values"""
133133
assert m.string_view_chars("Hi") == [72, 105]
134134
assert m.string_view_chars("Hi 🎂") == [72, 105, 32, 0xf0, 0x9f, 0x8e, 0x82]
135-
assert m.string_view16_chars("Hi 🎂") == [72, 105, 32, 0xd83c, 0xdf82]
136-
assert m.string_view32_chars("Hi 🎂") == [72, 105, 32, 127874]
135+
assert m.string_view16_chars(u"Hi 🎂") == [72, 105, 32, 0xd83c, 0xdf82]
136+
assert m.string_view32_chars(u"Hi 🎂") == [72, 105, 32, 127874]
137137
if hasattr(m, "has_u8string"):
138138
assert m.string_view8_chars("Hi") == [72, 105]
139-
assert m.string_view8_chars("Hi 🎂") == [72, 105, 32, 0xf0, 0x9f, 0x8e, 0x82]
139+
assert m.string_view8_chars(u"Hi 🎂") == [72, 105, 32, 0xf0, 0x9f, 0x8e, 0x82]
140140

141-
assert m.string_view_return() == "utf8 secret 🎂"
142-
assert m.string_view16_return() == "utf16 secret 🎂"
143-
assert m.string_view32_return() == "utf32 secret 🎂"
141+
assert m.string_view_return() == u"utf8 secret 🎂"
142+
assert m.string_view16_return() == u"utf16 secret 🎂"
143+
assert m.string_view32_return() == u"utf32 secret 🎂"
144144
if hasattr(m, "has_u8string"):
145-
assert m.string_view8_return() == "utf8 secret 🎂"
145+
assert m.string_view8_return() == u"utf8 secret 🎂"
146146

147147
with capture:
148148
m.string_view_print("Hi")
149149
m.string_view_print("utf8 🎂")
150-
m.string_view16_print("utf16 🎂")
151-
m.string_view32_print("utf32 🎂")
152-
assert capture == """
150+
m.string_view16_print(u"utf16 🎂")
151+
m.string_view32_print(u"utf32 🎂")
152+
assert capture == u"""
153153
Hi 2
154154
utf8 🎂 9
155155
utf16 🎂 8
@@ -158,18 +158,18 @@ def test_string_view(capture):
158158
if hasattr(m, "has_u8string"):
159159
with capture:
160160
m.string_view8_print("Hi")
161-
m.string_view8_print("utf8 🎂")
162-
assert capture == """
161+
m.string_view8_print(u"utf8 🎂")
162+
assert capture == u"""
163163
Hi 2
164164
utf8 🎂 9
165165
"""
166166

167167
with capture:
168168
m.string_view_print("Hi, ascii")
169169
m.string_view_print("Hi, utf8 🎂")
170-
m.string_view16_print("Hi, utf16 🎂")
171-
m.string_view32_print("Hi, utf32 🎂")
172-
assert capture == """
170+
m.string_view16_print(u"Hi, utf16 🎂")
171+
m.string_view32_print(u"Hi, utf32 🎂")
172+
assert capture == u"""
173173
Hi, ascii 9
174174
Hi, utf8 🎂 13
175175
Hi, utf16 🎂 12
@@ -178,8 +178,8 @@ def test_string_view(capture):
178178
if hasattr(m, "has_u8string"):
179179
with capture:
180180
m.string_view8_print("Hi, ascii")
181-
m.string_view8_print("Hi, utf8 🎂")
182-
assert capture == """
181+
m.string_view8_print(u"Hi, utf8 🎂")
182+
assert capture == u"""
183183
Hi, ascii 9
184184
Hi, utf8 🎂 13
185185
"""

0 commit comments

Comments
 (0)