]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-98513: Test abstract methods of some `collections` types (GH-98516) (#99226)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 8 Nov 2022 02:45:08 +0000 (18:45 -0800)
committerGitHub <noreply@github.com>
Tue, 8 Nov 2022 02:45:08 +0000 (18:45 -0800)
(cherry picked from commit a309ad9f76db4ab9a8f933ab1ffea78ecaca827f)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/test/test_collections.py

index db7f9e7beb3ee1fd82fb751d99fd54fed9e0d36d..5da446a13da43c36a51507d1d2712b7307de9aaa 100644 (file)
@@ -802,6 +802,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)
@@ -852,6 +854,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)
@@ -1935,6 +1939,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]: