Skip to content

gh-126417: validate ABC methods on multiprocessing proxy types #126454

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 5 commits into from
Nov 11, 2024
Merged
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
22 changes: 22 additions & 0 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,19 @@ def test_list_isinstance(self):
a = self.list()
self.assertIsInstance(a, collections.abc.MutableSequence)

# MutableSequence also has __iter__, but we can iterate over
# ListProxy using __getitem__ instead. Adding __iter__ to ListProxy
# would change the behavior of a list modified during iteration.
mutable_sequence_methods = (
'__contains__', '__delitem__', '__getitem__', '__iadd__',
'__len__', '__reversed__', '__setitem__', 'append',
'clear', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
'reverse',
)
for name in mutable_sequence_methods:
with self.subTest(name=name):
self.assertTrue(callable(getattr(a, name)))

def test_list_iter(self):
a = self.list(list(range(10)))
it = iter(a)
Expand Down Expand Up @@ -2380,6 +2393,15 @@ def test_dict_isinstance(self):
a = self.dict()
self.assertIsInstance(a, collections.abc.MutableMapping)

mutable_mapping_methods = (
'__contains__', '__delitem__', '__eq__', '__getitem__', '__iter__',
'__len__', '__ne__', '__setitem__', 'clear', 'get', 'items',
'keys', 'pop', 'popitem', 'setdefault', 'update', 'values',
)
for name in mutable_mapping_methods:
with self.subTest(name=name):
self.assertTrue(callable(getattr(a, name)))

def test_dict_iter(self):
d = self.dict()
indices = list(range(65, 70))
Expand Down
Loading