-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
gh-137463: Update validate_abstract_methods
in test_collections.py
#137464
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
sobolevn
merged 1 commit into
python:main
from
guilhermeleobas:guilhermeleobas/fix-collections-test
Aug 7, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -736,7 +736,7 @@ def validate_abstract_methods(self, abc, *names): | |
stubs = methodstubs.copy() | ||
del stubs[name] | ||
C = type('C', (abc,), stubs) | ||
self.assertRaises(TypeError, C, name) | ||
self.assertRaises(TypeError, C) | ||
|
||
def validate_isinstance(self, abc, name): | ||
stub = lambda s, *args: 0 | ||
|
@@ -963,7 +963,7 @@ class AnextOnly: | |
async def __anext__(self): | ||
raise StopAsyncIteration | ||
self.assertNotIsInstance(AnextOnly(), AsyncIterator) | ||
self.validate_abstract_methods(AsyncIterator, '__anext__', '__aiter__') | ||
self.validate_abstract_methods(AsyncIterator, '__anext__') | ||
|
||
def test_Iterable(self): | ||
# Check some non-iterables | ||
|
@@ -1159,7 +1159,7 @@ def test_Iterator(self): | |
for x in samples: | ||
self.assertIsInstance(x, Iterator) | ||
self.assertIsSubclass(type(x), Iterator) | ||
self.validate_abstract_methods(Iterator, '__next__', '__iter__') | ||
self.validate_abstract_methods(Iterator, '__next__') | ||
|
||
# Issue 10565 | ||
class NextOnly: | ||
|
@@ -1843,8 +1843,7 @@ def test_Mapping(self): | |
for sample in [dict]: | ||
self.assertIsInstance(sample(), Mapping) | ||
self.assertIsSubclass(sample, Mapping) | ||
self.validate_abstract_methods(Mapping, '__contains__', '__iter__', '__len__', | ||
'__getitem__') | ||
self.validate_abstract_methods(Mapping, '__iter__', '__len__', '__getitem__') | ||
class MyMapping(Mapping): | ||
def __len__(self): | ||
return 0 | ||
|
@@ -1859,7 +1858,7 @@ def test_MutableMapping(self): | |
for sample in [dict]: | ||
self.assertIsInstance(sample(), MutableMapping) | ||
self.assertIsSubclass(sample, MutableMapping) | ||
self.validate_abstract_methods(MutableMapping, '__contains__', '__iter__', '__len__', | ||
self.validate_abstract_methods(MutableMapping, '__iter__', '__len__', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
'__getitem__', '__setitem__', '__delitem__') | ||
|
||
def test_MutableMapping_subclass(self): | ||
|
@@ -1898,8 +1897,7 @@ def test_Sequence(self): | |
self.assertIsInstance(memoryview(b""), Sequence) | ||
self.assertIsSubclass(memoryview, Sequence) | ||
self.assertIsSubclass(str, Sequence) | ||
self.validate_abstract_methods(Sequence, '__contains__', '__iter__', '__len__', | ||
'__getitem__') | ||
self.validate_abstract_methods(Sequence, '__len__', '__getitem__') | ||
|
||
def test_Sequence_mixins(self): | ||
class SequenceSubclass(Sequence): | ||
|
@@ -1954,8 +1952,8 @@ def test_MutableSequence(self): | |
self.assertIsSubclass(sample, MutableSequence) | ||
self.assertIsSubclass(array.array, MutableSequence) | ||
self.assertNotIsSubclass(str, MutableSequence) | ||
self.validate_abstract_methods(MutableSequence, '__contains__', '__iter__', | ||
'__len__', '__getitem__', '__setitem__', '__delitem__', 'insert') | ||
self.validate_abstract_methods(MutableSequence, '__len__', '__getitem__', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And |
||
'__setitem__', '__delitem__', 'insert') | ||
|
||
def test_MutableSequence_mixins(self): | ||
# Test the mixins of MutableSequence by creating a minimal concrete | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
AsyncIterator.__aiter__
is not abstract, it is correct to remove it here.