Skip to content

Update Lib/test/support/__init__.py from 3.13.5 #6037

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 22 commits into from
Jul 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
995 changes: 865 additions & 130 deletions Lib/test/pickletester.py

Large diffs are not rendered by default.

1,191 changes: 767 additions & 424 deletions Lib/test/support/__init__.py

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions Lib/test/test_collections.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Unit tests for collections.py."""

import array
import collections
import copy
import doctest
Expand Down Expand Up @@ -469,6 +470,8 @@ def test_module_parameter(self):
NT = namedtuple('NT', ['x', 'y'], module=collections)
self.assertEqual(NT.__module__, collections)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_instance(self):
Point = namedtuple('Point', 'x y')
p = Point(11, 22)
Expand All @@ -490,12 +493,8 @@ def test_instance(self):
self.assertEqual(p._replace(x=1), (1, 22)) # test _replace method
self.assertEqual(p._asdict(), dict(x=11, y=22)) # test _asdict method

try:
with self.assertRaises(TypeError):
p._replace(x=1, error=2)
except ValueError:
pass
else:
self._fail('Did not detect an incorrect fieldname')

# verify that field string can have commas
Point = namedtuple('Point', 'x, y')
Expand Down Expand Up @@ -547,7 +546,9 @@ def test_odd_sizes(self):
self.assertEqual(Dot(1)._replace(d=999), (999,))
self.assertEqual(Dot(1)._fields, ('d',))

n = support.EXCEEDS_RECURSION_LIMIT
@support.requires_resource('cpu')
def test_large_size(self):
n = support.exceeds_recursion_limit()
names = list(set(''.join([choice(string.ascii_letters)
for j in range(10)]) for i in range(n)))
n = len(names)
Expand Down Expand Up @@ -1150,6 +1151,7 @@ class NonCol(ColImpl):
self.assertFalse(issubclass(NonCol, Collection))
self.assertFalse(isinstance(NonCol(), Collection))


def test_Iterator(self):
non_samples = [None, 42, 3.14, 1j, b"", "", (), [], {}, set()]
for x in non_samples:
Expand Down Expand Up @@ -1985,6 +1987,7 @@ def test_MutableSequence(self):
for sample in [list, bytearray, deque]:
self.assertIsInstance(sample(), MutableSequence)
self.assertTrue(issubclass(sample, MutableSequence))
self.assertTrue(issubclass(array.array, MutableSequence))
self.assertFalse(issubclass(str, MutableSequence))
self.validate_abstract_methods(MutableSequence, '__contains__', '__iter__',
'__len__', '__getitem__', '__setitem__', '__delitem__', 'insert')
Expand Down
5 changes: 2 additions & 3 deletions Lib/test/test_dictviews.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import collections.abc
import copy
import pickle
import sys
import unittest
from test.support import C_RECURSION_LIMIT
from test.support import get_c_recursion_limit

class DictSetTest(unittest.TestCase):

Expand Down Expand Up @@ -282,7 +281,7 @@ def test_recursive_repr(self):
@unittest.expectedFailure
def test_deeply_nested_repr(self):
d = {}
for i in range(C_RECURSION_LIMIT//2 + 100):
for i in range(get_c_recursion_limit()//2 + 100):
d = {42: d.values()}
self.assertRaises(RecursionError, repr, d)

Expand Down
Loading
Loading