mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
collections.abc: Test that if an object is a Coroutine it is also an Awaitable
This commit is contained in:
parent
71f574f707
commit
aded55c6e3
1 changed files with 16 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue