Update list-related CPython tests to v3.14.2 (#7000)

This commit is contained in:
Jeong, YunWon authored and GitHub committed 2026-02-05 20:30:17 +09:00
1 parent bbb6c66a29
commit 8ffb8f5512
3 files changed
+51 -12

No files matched your search

+24 -3
View File
@@ -1,8 +1,10 @@
import signal
import sys
import textwrap
from test import list_tests
from test import list_tests, support
from test.support import cpython_only
from test.support.script_helper import assert_python_ok
from test.support.import_helper import import_module
from test.support.script_helper import assert_python_failure, assert_python_ok
import pickle
import unittest
@@ -48,7 +50,7 @@ class ListTest(list_tests.CommonTest):
with self.assertRaisesRegex(TypeError, 'keyword argument'):
list(sequence=[])
@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_keywords_in_subclass(self):
class subclass(list):
pass
@@ -329,6 +331,25 @@ class ListTest(list_tests.CommonTest):
a.append(4)
self.assertEqual(list(it), [])
@support.cpython_only
def test_no_memory(self):
# gh-118331: Make sure we don't crash if list allocation fails
import_module("_testcapi")
code = textwrap.dedent("""
import _testcapi, sys
# Prime the freelist
l = [None]
del l
_testcapi.set_nomemory(0)
l = [None]
""")
rc, _, _ = assert_python_failure("-c", code)
if support.MS_WINDOWS:
# STATUS_ACCESS_VIOLATION
self.assertNotEqual(rc, 0xC0000005)
else:
self.assertNotEqual(rc, -int(signal.SIGSEGV))
def test_deopt_from_append_list(self):
# gh-132011: it used to crash, because
# of `CALL_LIST_APPEND` specialization failure.
+26 -5
View File
@@ -609,7 +609,7 @@ class ListComprehensionTest(unittest.TestCase):
result = snapshot = None
try:
result = [{func}(value) for value in value]
except:
except ValueError:
snapshot = value
raise
"""
@@ -643,13 +643,12 @@ class ListComprehensionTest(unittest.TestCase):
value = [1, None]
try:
[v for v in value].sort()
except:
except TypeError:
pass
"""
self._check_in_scopes(code, {"value": [1, None]})
# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_frame_locals(self):
code = """
val = "a" in [sys._getframe().f_locals for a in [0]][0]
@@ -718,7 +717,7 @@ class ListComprehensionTest(unittest.TestCase):
def test_exception_locations(self):
# The location of an exception raised from __init__ or
# __next__ should should be the iterator expression
# __next__ should be the iterator expression
def init_raises():
try:
@@ -752,6 +751,28 @@ class ListComprehensionTest(unittest.TestCase):
self.assertEqual(f.line[f.colno - indent : f.end_colno - indent],
expected)
def test_only_calls_dunder_iter_once(self):
class Iterator:
def __init__(self):
self.val = 0
def __next__(self):
if self.val == 2:
raise StopIteration
self.val += 1
return self.val
# No __iter__ method
class C:
def __iter__(self):
return Iterator()
self.assertEqual([1, 2], [i for i in C()])
__test__ = {'doctests' : doctests}
def load_tests(loader, tests, pattern):
+1 -4
View File
@@ -3,7 +3,6 @@
from collections import UserList
from test import list_tests
import unittest
from test import support
class UserListTest(list_tests.CommonTest):
@@ -69,9 +68,7 @@ class UserListTest(list_tests.CommonTest):
# Decorate existing test with recursion limit, because
# the test is for C structure, but `UserList` is a Python structure.
test_repr_deep = support.infinite_recursion(25)(
list_tests.CommonTest.test_repr_deep,
)
test_repr_deep = list_tests.CommonTest.test_repr_deep
if __name__ == "__main__":
unittest.main()