gh-98513: Test abstract methods of some `collections` types (#98516)

This commit is contained in:
Nikita Sobolev 2022-11-08 04:48:23 +03:00 committed by GitHub
parent c32bc1bffd
commit a309ad9f76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -810,6 +810,8 @@ class TestOneTrickPonyABCs(ABCTestCase):
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)
@ -860,6 +862,8 @@ class TestOneTrickPonyABCs(ABCTestCase):
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)
@ -1943,6 +1947,7 @@ class TestCollectionABCs(ABCTestCase):
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]: