[3.11] gh-98513: Test abstract methods of some collections types (GH-98516) (#99226)

(cherry picked from commit a309ad9f76)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2022-11-07 18:45:08 -08:00 committed by GitHub
parent 42fb233c52
commit 1add2393a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -802,6 +802,8 @@ def throw(self, typ, val=None, tb=None):
def __await__(self):
yield
self.validate_abstract_methods(Awaitable, '__await__')
non_samples = [None, int(), gen(), object()]
for x in non_samples:
self.assertNotIsInstance(x, Awaitable)
@ -852,6 +854,8 @@ def throw(self, typ, val=None, tb=None):
def __await__(self):
yield
self.validate_abstract_methods(Coroutine, '__await__', 'send', 'throw')
non_samples = [None, int(), gen(), object(), Bar()]
for x in non_samples:
self.assertNotIsInstance(x, Coroutine)
@ -1935,6 +1939,7 @@ def test_ByteString(self):
self.assertFalse(issubclass(sample, ByteString))
self.assertNotIsInstance(memoryview(b""), ByteString)
self.assertFalse(issubclass(memoryview, ByteString))
self.validate_abstract_methods(ByteString, '__getitem__', '__len__')
def test_MutableSequence(self):
for sample in [tuple, str, bytes]: