FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-158445: Skip invalid UCS-4 tests if Python is built with assertions by vstinner · Pull Request #158604 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 10 additions & 2 deletions Lib/test/test_capi/test_unicode.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ def test_fromkindanddata(self):

# Test invalid UCS-4 string. Create an invalid string in release mode,
# or raise SystemError in debug mode.
built_with_assert = support.built_with_c_assertions()
for invalid_char in (INVALID_CHAR, MAX_INVALID_CHAR):
with self.subTest(invalid_char=invalid_char):
# Test single character
Expand All @@ -325,9 +326,12 @@ def test_fromkindanddata(self):
s = 'valid'.encode(enc4) + ucs4_char
if support.Py_DEBUG:
self.assertRaises(SystemError, fromkindanddata, 4, s)
else:
elif not built_with_assert :
result = fromkindanddata(4, s)
assert_invalid_string(self, result)
else:
# PyUnicode_FromKindAndData() fails with an assertion error
pass

def test_substring(self):
"""Test PyUnicode_Substring()"""
Expand Down Expand Up @@ -2170,6 +2174,7 @@ def test_ucs4(self):

# Invalid UCS-4 characters. Create an invalid string in release mode,
# or raise SystemError in debug mode.
built_with_assert = support.built_with_c_assertions()
writer = self.create_writer(0)
for invalid_char in (INVALID_CHAR, MAX_INVALID_CHAR):
with self.subTest(invalid_char=invalid_char):
Expand All @@ -2189,9 +2194,12 @@ def test_ucs4(self):

if support.Py_DEBUG:
self.assertEqual(writer.finish(), '')
else:
elif not built_with_assert:
result = writer.finish()
assert_invalid_string(self, result)
else:
# PyUnicodeWriter_Finish() fails with an assertion error
pass

# Invalid size
writer = self.create_writer(0)
Expand Down
Loading

Back | FazBrowse Home | New Git URL