summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_collections.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-05-14 03:41:55 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-05-14 03:41:55 (GMT)
commitaded55c6e3d893d7543bd642d7f0a6609d26e2e3 (patch)
treedeb12787d7e5c420d0db4d6a2d3075912f4ea183 /Lib/test/test_collections.py
parent71f574f707e8f1872c128838d7c20e492117e9ef (diff)
downloadcpython-aded55c6e3d893d7543bd642d7f0a6609d26e2e3.zip
cpython-aded55c6e3d893d7543bd642d7f0a6609d26e2e3.tar.gz
cpython-aded55c6e3d893d7543bd642d7f0a6609d26e2e3.tar.bz2
collections.abc: Test that if an object is a Coroutine it is also an Awaitable
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r--Lib/test/test_collections.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 2bb5538..3d1db5c 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -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