Skip to content

Commit

Permalink
gh-98513: Test abstract methods of some collections types (GH-98516)
Browse files Browse the repository at this point in the history
(cherry picked from commit a309ad9)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
  • Loading branch information
miss-islington and sobolevn committed Nov 8, 2022
1 parent d2cb0f9 commit a5d3e1d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Lib/test/test_collections.py
Expand Up @@ -788,6 +788,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)
Expand Down Expand Up @@ -838,6 +840,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)
Expand Down Expand Up @@ -1921,6 +1925,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]:
Expand Down

0 comments on commit a5d3e1d

Please sign in to comment.