]> granicus.if.org Git - python/commitdiff
collections.abc: Test that if an object is a Coroutine it is also an Awaitable
authorYury Selivanov <yselivanov@sprymix.com>
Thu, 14 May 2015 03:41:55 +0000 (23:41 -0400)
committerYury Selivanov <yselivanov@sprymix.com>
Thu, 14 May 2015 03:41:55 +0000 (23:41 -0400)
Lib/test/test_collections.py

index 2bb55385e3159ebf7eceec93cc97c2aa4af73d1b..3d1db5ca0e49a839ee47c73881769f0850280e57 100644 (file)
@@ -495,6 +495,22 @@ class TestOneTrickPonyABCs(ABCTestCase):
         self.assertIsInstance(c, Awaitable)
         c.close() # awoid RuntimeWarning that coro() was not awaited
 
+        class CoroLike:
+            def send(self, value):
+                pass
+            def throw(self, typ, val=None, tb=None):
+                pass
+            def close(self):
+                pass
+        Coroutine.register(CoroLike)
+        try:
+            self.assertTrue(isinstance(CoroLike(), Awaitable))
+            self.assertTrue(issubclass(CoroLike, Awaitable))
+            CoroLike = None
+        finally:
+            support.gc_collect() # Kill CoroLike to clean-up ABCMeta cache
+
+
     def test_Coroutine(self):
         def gen():
             yield