Content-Length: 606907 | pFad | http://github.com/RustPython/RustPython/pull/5953/commits/58602a3e811a790d28c686ab4b0c1462d7f4d501

5E Update str related tests from 3.13.5 by ShaharNaveh · Pull Request #5953 · RustPython/RustPython · GitHub
Skip to content

Update str related tests from 3.13.5 #5953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply RustPython patches
  • Loading branch information
ShaharNaveh committed Jul 12, 2025
commit 58602a3e811a790d28c686ab4b0c1462d7f4d501
9 changes: 8 additions & 1 deletion Lib/test/string_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ def test_expandtabs(self):

self.checkraises(TypeError, 'hello', 'expandtabs', 42, 42)
# This test is only valid when sizeof(int) == sizeof(void*) == 4.
if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4:
# XXX RUSTPYTHON TODO: expandtabs overflow checks
if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4 and False:
self.checkraises(OverflowError,
'\ta\n\tb', 'expandtabs', sys.maxsize)

Expand Down Expand Up @@ -779,6 +780,7 @@ def test_replace_uses_two_way_maxcount(self):
self.checkequal(AABAA + "ccc",
AABAA + ABBA, 'replace', ABBA, "ccc", 2)

@unittest.skip("TODO: RUSTPYTHON, may only apply to 32-bit platforms")
@unittest.skipIf(sys.maxsize > (1 << 32) or struct.calcsize('P') != 4,
'only applies to 32-bit platforms')
def test_replace_overflow(self):
Expand Down Expand Up @@ -1246,6 +1248,9 @@ def test___contains__(self):
self.checkequal(False, 'asd', '__contains__', 'asdf')
self.checkequal(False, '', '__contains__', 'asdf')


# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_subscript(self):
self.checkequal('a', 'abc', '__getitem__', 0)
self.checkequal('c', 'abc', '__getitem__', -1)
Expand Down Expand Up @@ -1499,6 +1504,8 @@ def test_none_arguments(self):
self.checkequal(True, s, 'startswith', 'h', None, -2)
self.checkequal(False, s, 'startswith', 'x', None, None)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_find_etc_raise_correct_error_messages(self):
# issue 11828
s = 'hello'
Expand Down
26 changes: 23 additions & 3 deletions Lib/test/test_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ def test_constructor_value_errors(self):
self.assertRaises(ValueError, self.type2test, [sys.maxsize+1])
self.assertRaises(ValueError, self.type2test, [10**100])

# TODO: RUSTPYTHON
@unittest.expectedFailure
@bigaddrspacetest
def test_constructor_overflow(self):
size = MAX_Py_ssize_t
Expand Down Expand Up @@ -324,6 +326,8 @@ def test_decode(self):
# Default encoding is utf-8
self.assertEqual(self.type2test(b'\xe2\x98\x83').decode(), '\u2603')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_check_encoding_errors(self):
# bpo-37388: bytes(str) and bytes.encode() must check encoding
# and errors arguments in dev mode
Expand Down Expand Up @@ -968,6 +972,8 @@ def test_integer_arguments_out_of_byte_range(self):
self.assertRaises(ValueError, method, 256)
self.assertRaises(ValueError, method, 9999)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_find_etc_raise_correct_error_messages(self):
# issue 11828
b = self.type2test(b'hello')
Expand All @@ -987,6 +993,8 @@ def test_find_etc_raise_correct_error_messages(self):
self.assertRaisesRegex(TypeError, r'\bendswith\b', b.endswith,
x, None, None, None)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_free_after_iterating(self):
test.support.check_free_after_iterating(self, iter, self.type2test)
test.support.check_free_after_iterating(self, reversed, self.type2test)
Expand Down Expand Up @@ -1575,6 +1583,11 @@ def test_irepeat_1char(self):
self.assertEqual(b, b1)
self.assertIs(b, b1)

# NOTE: RUSTPYTHON:
#
# The second instance of self.assertGreater was replaced with
# self.assertGreaterEqual since, in RustPython, the underlying storage
# is a Vec which doesn't require trailing null byte.
def test_alloc(self):
b = bytearray()
alloc = b.__alloc__()
Expand All @@ -1583,10 +1596,15 @@ def test_alloc(self):
for i in range(100):
b += b"x"
alloc = b.__alloc__()
self.assertGreater(alloc, len(b)) # including trailing null byte
self.assertGreaterEqual(alloc, len(b)) # NOTE: RUSTPYTHON patched
if alloc not in seq:
seq.append(alloc)

# NOTE: RUSTPYTHON:
#
# The usages of self.assertGreater were replaced with
# self.assertGreaterEqual since, in RustPython, the underlying storage
# is a Vec which doesn't require trailing null byte.
def test_init_alloc(self):
b = bytearray()
def g():
Expand All @@ -1597,12 +1615,12 @@ def g():
self.assertEqual(len(b), len(a))
self.assertLessEqual(len(b), i)
alloc = b.__alloc__()
self.assertGreater(alloc, len(b)) # including trailing null byte
self.assertGreaterEqual(alloc, len(b)) # NOTE: RUSTPYTHON patched
b.__init__(g())
self.assertEqual(list(b), list(range(1, 100)))
self.assertEqual(len(b), 99)
alloc = b.__alloc__()
self.assertGreater(alloc, len(b))
self.assertGreaterEqual(alloc, len(b)) # NOTE: RUSTPYTHON patched

def test_extend(self):
orig = b'hello'
Expand Down Expand Up @@ -2071,6 +2089,7 @@ def test_join(self):
s3 = s1.join([b"abcd"])
self.assertIs(type(s3), self.basetype)

@unittest.skip("TODO: RUSTPYTHON, Fails on ByteArraySubclassWithSlotsTest")
def test_pickle(self):
a = self.type2test(b"abcd")
a.x = 10
Expand All @@ -2085,6 +2104,7 @@ def test_pickle(self):
self.assertEqual(type(a.z), type(b.z))
self.assertFalse(hasattr(b, 'y'))

@unittest.skip("TODO: RUSTPYTHON, Fails on ByteArraySubclassWithSlotsTest")
def test_copy(self):
a = self.type2test(b"abcd")
a.x = 10
Expand Down
34 changes: 34 additions & 0 deletions Lib/test/test_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ def __str__(self): return self.sval
self.checkraises(TypeError, ' ', 'join', [1, 2, 3])
self.checkraises(TypeError, ' ', 'join', ['1', '2', 3])

@unittest.skip("TODO: RUSTPYTHON, oom handling")
@unittest.skipIf(sys.maxsize > 2**32,
'needs too much memory on a 64-bit platform')
def test_join_overflow(self):
Expand Down Expand Up @@ -792,6 +793,8 @@ def test_isdecimal(self):
for ch in ['\U0001D7F6', '\U00011066', '\U000104A0']:
self.assertTrue(ch.isdecimal(), '{!a} is decimal.'.format(ch))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_isdigit(self):
super().test_isdigit()
self.checkequalnofix(True, '\u2460', 'isdigit')
Expand Down Expand Up @@ -937,6 +940,8 @@ def test_upper(self):
self.assertEqual('\U0008fffe'.upper(), '\U0008fffe')
self.assertEqual('\u2177'.upper(), '\u2167')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_capitalize(self):
string_tests.StringLikeTest.test_capitalize(self)
self.assertEqual('\U0001044F'.capitalize(), '\U00010427')
Expand All @@ -954,6 +959,8 @@ def test_capitalize(self):
self.assertEqual('finnish'.capitalize(), 'Finnish')
self.assertEqual('A\u0345\u03a3'.capitalize(), 'A\u0345\u03c2')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_title(self):
super().test_title()
self.assertEqual('\U0001044F'.title(), '\U00010427')
Expand All @@ -971,6 +978,8 @@ def test_title(self):
self.assertEqual('A\u03a3 \u1fa1xy'.title(), 'A\u03c2 \u1fa9xy')
self.assertEqual('A\u03a3A'.title(), 'A\u03c3a')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_swapcase(self):
string_tests.StringLikeTest.test_swapcase(self)
self.assertEqual('\U0001044F'.swapcase(), '\U00010427')
Expand Down Expand Up @@ -1070,6 +1079,8 @@ def test_issue18183(self):
'\U00100000'.ljust(3, '\U00010000')
'\U00100000'.rjust(3, '\U00010000')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_format(self):
self.assertEqual(''.format(), '')
self.assertEqual('a'.format(), 'a')
Expand Down Expand Up @@ -1453,16 +1464,21 @@ def __getitem__(self, key):
self.assertRaises(TypeError, '{a}'.format_map, [])
self.assertRaises(ZeroDivisionError, '{a}'.format_map, BadMapping())

@unittest.skip("TODO: RUSTPYTHON, killed for chewing up RAM")
def test_format_huge_precision(self):
format_string = ".{}f".format(sys.maxsize + 1)
with self.assertRaises(ValueError):
result = format(2.34, format_string)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_format_huge_width(self):
format_string = "{}f".format(sys.maxsize + 1)
with self.assertRaises(ValueError):
result = format(2.34, format_string)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_format_huge_item_number(self):
format_string = "{{{}:.6f}}".format(sys.maxsize + 1)
with self.assertRaises(ValueError):
Expand Down Expand Up @@ -1498,6 +1514,8 @@ def __format__(self, spec):
self.assertEqual('{:{f}}{g}{}'.format(1, 3, g='g', f=2), ' 1g3')
self.assertEqual('{f:{}}{}{g}'.format(2, 4, f=1, g='g'), ' 14g')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_formatting(self):
string_tests.StringLikeTest.test_formatting(self)
# Testing Unicode formatting strings...
Expand Down Expand Up @@ -1746,6 +1764,8 @@ def __str__(self):
'character buffers are decoded to unicode'
)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_constructor_keyword_args(self):
"""Pass various keyword argument combinations to the constructor."""
# The object argument can be passed as a keyword.
Expand All @@ -1755,6 +1775,8 @@ def test_constructor_keyword_args(self):
self.assertEqual(str(b'foo', errors='strict'), 'foo') # not "b'foo'"
self.assertEqual(str(object=b'foo', errors='strict'), 'foo')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_constructor_defaults(self):
"""Check the constructor argument defaults."""
# The object argument defaults to '' or b''.
Expand All @@ -1766,6 +1788,8 @@ def test_constructor_defaults(self):
# The errors argument defaults to strict.
self.assertRaises(UnicodeDecodeError, str, utf8_cent, encoding='ascii')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_codecs_utf7(self):
utfTests = [
('A\u2262\u0391.', b'A+ImIDkQ.'), # RFC2152 example
Expand Down Expand Up @@ -2275,6 +2299,8 @@ def test_codecs_errors(self):
self.assertRaises(ValueError, complex, "\ud800")
self.assertRaises(ValueError, complex, "\udf00")

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_codecs(self):
# Encoding
self.assertEqual('hello'.encode('ascii'), b'hello')
Expand Down Expand Up @@ -2404,6 +2430,8 @@ def test_ucs4(self):
else:
self.fail("Should have raised UnicodeDecodeError")

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_conversion(self):
# Make sure __str__() works properly
class StrWithStr(str):
Expand Down Expand Up @@ -2452,6 +2480,7 @@ def test_printable_repr(self):
# This test only affects 32-bit platforms because expandtabs can only take
# an int as the max value, not a 64-bit C long. If expandtabs is changed
# to take a 64-bit long, this test should apply to all platforms.
@unittest.skip("TODO: RUSTPYTHON, oom handling")
@unittest.skipIf(sys.maxsize > (1 << 32) or struct.calcsize('P') != 4,
'only applies to 32-bit platforms')
def test_expandtabs_overflows_gracefully(self):
Expand All @@ -2462,6 +2491,7 @@ def test_expandtabs_optimization(self):
s = 'abc'
self.assertIs(s.expandtabs(), s)

@unittest.skip("TODO: RUSTPYTHON, aborted: memory allocation of 9223372036854775759 bytes failed")
def test_raiseMemError(self):
asciifields = "nnb"
compactfields = asciifields + "nP"
Expand Down Expand Up @@ -2601,10 +2631,14 @@ def test_compare(self):
self.assertTrue(astral >= bmp2)
self.assertFalse(astral >= astral2)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_free_after_iterating(self):
support.check_free_after_iterating(self, iter, str)
support.check_free_after_iterating(self, reversed, str)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_check_encoding_errors(self):
# bpo-37388: str(bytes) and str.decode() must check encoding and errors
# arguments in dev mode
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_unicode_identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def test_non_bmp_normalized(self):
𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = 1
self.assertIn("Unicode", dir())

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_invalid(self):
try:
from test.tokenizedata import badsyntax_3131
Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/RustPython/RustPython/pull/5953/commits/58602a3e811a790d28c686ab4b0c1462d7f4d501

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy