Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c642aef

Browse files
authored
Merge pull request #5481 from arihant2math/builtins-312
Update tests for builtin objects to python 3.12.8
2 parents 16d8bab + 396df1a commit c642aef

File tree

6 files changed

+728
-83
lines changed

6 files changed

+728
-83
lines changed

Lib/ctypes/test/test_numbers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ def test_alignments(self):
147147

148148
# alignment of the type...
149149
self.assertEqual((code, alignment(t)),
150-
(code, align))
150+
(code, align))
151151
# and alignment of an instance
152152
self.assertEqual((code, alignment(t())),
153-
(code, align))
153+
(code, align))
154154

155155
def test_int_from_address(self):
156156
from array import array

Lib/test/support/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,3 +2555,20 @@ def adjust_int_max_str_digits(max_digits):
25552555
skip_on_s390x = unittest.skipIf(hasattr(os, 'uname') and os.uname().machine == 's390x',
25562556
'skipped on s390x')
25572557
HAVE_ASAN_FORK_BUG = check_sanitizer(address=True)
2558+
2559+
# From python 3.12.8
2560+
class BrokenIter:
2561+
def __init__(self, init_raises=False, next_raises=False, iter_raises=False):
2562+
if init_raises:
2563+
1/0
2564+
self.next_raises = next_raises
2565+
self.iter_raises = iter_raises
2566+
2567+
def __next__(self):
2568+
if self.next_raises:
2569+
1/0
2570+
2571+
def __iter__(self):
2572+
if self.iter_raises:
2573+
1/0
2574+
return self

Lib/test/test_float.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def check(s):
133133
with self.assertRaises(ValueError, msg='float(%r)' % (s,)) as cm:
134134
float(s)
135135
self.assertEqual(str(cm.exception),
136-
'could not convert string to float: %r' % (s,))
136+
'could not convert string to float: %r' % (s,))
137137

138138
check('\xbd')
139139
check('123\xbd')
@@ -155,7 +155,9 @@ def check(s):
155155
# non-UTF-8 byte string
156156
check(b'123\xa0')
157157

158-
@support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
158+
# TODO: RUSTPYTHON
159+
@unittest.skip("RustPython panics on this")
160+
@support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE', '')
159161
def test_float_with_comma(self):
160162
# set locale to something that doesn't use '.' for the decimal point
161163
# float must not accept the locale specific decimal point but
@@ -290,11 +292,11 @@ def test_is_integer(self):
290292

291293
def test_floatasratio(self):
292294
for f, ratio in [
293-
(0.875, (7, 8)),
294-
(-0.875, (-7, 8)),
295-
(0.0, (0, 1)),
296-
(11.5, (23, 2)),
297-
]:
295+
(0.875, (7, 8)),
296+
(-0.875, (-7, 8)),
297+
(0.0, (0, 1)),
298+
(11.5, (23, 2)),
299+
]:
298300
self.assertEqual(f.as_integer_ratio(), ratio)
299301

300302
for i in range(10000):
@@ -337,7 +339,7 @@ def test_float_containment(self):
337339
self.assertTrue((f,) == (f,), "(%r,) != (%r,)" % (f, f))
338340
self.assertTrue({f} == {f}, "{%r} != {%r}" % (f, f))
339341
self.assertTrue({f : None} == {f: None}, "{%r : None} != "
340-
"{%r : None}" % (f, f))
342+
"{%r : None}" % (f, f))
341343

342344
# identical containers
343345
l, t, s, d = [f], (f,), {f}, {f: None}
@@ -667,8 +669,6 @@ def test_float_specials_do_unpack(self):
667669
('<f', LE_FLOAT_NAN)]:
668670
struct.unpack(fmt, data)
669671

670-
# TODO: RUSTPYTHON
671-
@unittest.expectedFailure
672672
@support.requires_IEEE_754
673673
@unittest.skipIf(_testcapi is None, 'needs _testcapi')
674674
def test_serialized_float_rounding(self):
@@ -776,7 +776,7 @@ def test_issue35560(self):
776776
class ReprTestCase(unittest.TestCase):
777777
def test_repr(self):
778778
with open(os.path.join(os.path.split(__file__)[0],
779-
'floating_points.txt'), encoding="utf-8") as floats_file:
779+
'floating_points.txt'), encoding="utf-8") as floats_file:
780780
for line in floats_file:
781781
line = line.strip()
782782
if not line or line.startswith('#'):
@@ -826,7 +826,7 @@ def test_short_repr(self):
826826
'2.86438000439698e+28',
827827
'8.89142905246179e+28',
828828
'3.08578087079232e+35',
829-
]
829+
]
830830

831831
for s in test_strings:
832832
negs = '-'+s
@@ -883,7 +883,7 @@ def test_overflow(self):
883883
def test_previous_round_bugs(self):
884884
# particular cases that have occurred in bug reports
885885
self.assertEqual(round(562949953421312.5, 1),
886-
562949953421312.5)
886+
562949953421312.5)
887887
self.assertEqual(round(56294995342131.5, 3),
888888
56294995342131.5)
889889
# round-half-even
@@ -1133,7 +1133,7 @@ def test_invalid_inputs(self):
11331133
'0x1.\uff10p0',
11341134
'0x1p0 \n 0x2p0',
11351135
'0x1p0\0 0x1p0', # embedded null byte is not end of string
1136-
]
1136+
]
11371137
for x in invalid_inputs:
11381138
try:
11391139
result = fromHex(x)
@@ -1152,7 +1152,7 @@ def test_whitespace(self):
11521152
('1.0', 1.0),
11531153
('-0x.2', -0.125),
11541154
('-0.0', -0.0)
1155-
]
1155+
]
11561156
whitespace = [
11571157
'',
11581158
' ',
@@ -1162,7 +1162,7 @@ def test_whitespace(self):
11621162
'\f',
11631163
'\v',
11641164
'\r'
1165-
]
1165+
]
11661166
for inp, expected in value_pairs:
11671167
for lead in whitespace:
11681168
for trail in whitespace:

Lib/test/test_list.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ def test_basic(self):
2222

2323
if sys.maxsize == 0x7fffffff:
2424
# This test can currently only work on 32-bit machines.
25+
# XXX If/when PySequence_Length() returns a ssize_t, it should be
26+
# XXX re-enabled.
2527
# Verify clearing of bug #556025.
2628
# This assumes that the max data size (sys.maxint) == max
2729
# address size this also assumes that the address size is at
@@ -97,15 +99,15 @@ def imul(a, b): a *= b
9799
self.assertRaises((MemoryError, OverflowError), imul, lst, n)
98100

99101
# TODO: RUSTPYTHON
100-
@unittest.expectedFailure
102+
@unittest.skip("Crashes on windows debug build")
101103
def test_list_resize_overflow(self):
102104
# gh-97616: test new_allocated * sizeof(PyObject*) overflow
103105
# check in list_resize()
104106
lst = [0] * 65
105107
del lst[1:]
106108
self.assertEqual(len(lst), 1)
107109

108-
size = ((2 ** (tuple.__itemsize__ * 8) - 1) // 2)
110+
size = sys.maxsize
109111
with self.assertRaises((MemoryError, OverflowError)):
110112
lst * size
111113
with self.assertRaises((MemoryError, OverflowError)):
@@ -117,7 +119,7 @@ def check(n):
117119
l = [0] * n
118120
s = repr(l)
119121
self.assertEqual(s,
120-
'[' + ', '.join(['0'] * n) + ']')
122+
'[' + ', '.join(['0'] * n) + ']')
121123
check(10) # check our checking code
122124
check(1000000)
123125

@@ -206,6 +208,7 @@ class L(list): pass
206208
with self.assertRaises(TypeError):
207209
(3,) + L([1,2])
208210

211+
# TODO: RUSTPYTHON
209212
@unittest.skip("TODO: RUSTPYTHON; hang")
210213
def test_equal_operator_modifying_operand(self):
211214
# test fix for seg fault reported in bpo-38588 part 2.
@@ -232,6 +235,33 @@ def __eq__(self, other):
232235
list4 = [1]
233236
self.assertFalse(list3 == list4)
234237

238+
# TODO: RUSTPYTHON
239+
@unittest.skip("TODO: RUSTPYTHON; hang")
240+
def test_lt_operator_modifying_operand(self):
241+
# See gh-120298
242+
class evil:
243+
def __lt__(self, other):
244+
other.clear()
245+
return NotImplemented
246+
247+
a = [[evil()]]
248+
with self.assertRaises(TypeError):
249+
a[0] < a
250+
251+
def test_list_index_modifing_operand(self):
252+
# See gh-120384
253+
class evil:
254+
def __init__(self, lst):
255+
self.lst = lst
256+
def __iter__(self):
257+
yield from self.lst
258+
self.lst.clear()
259+
260+
lst = list(range(5))
261+
operand = evil(lst)
262+
with self.assertRaises(ValueError):
263+
lst[::-1] = operand
264+
235265
@cpython_only
236266
def test_preallocation(self):
237267
iterable = [0] * 10

0 commit comments

Comments
 (0)