return loop.run_until_complete(doit())
+class CoroLike:
+ def send(self, v):
+ pass
+
+ def throw(self, *exc):
+ pass
+
+ def close(self):
+ pass
+
+ def __await__(self):
+ pass
+
+
ONLYCERT = data_file('ssl_cert.pem')
ONLYKEY = data_file('ssl_key.pem')
SIGNED_CERTFILE = data_file('keycert3.pem')
# collections.abc.Coroutine, but lack cr_core or gi_code attributes
# (such as ones compiled with Cython).
- class Coro:
- def send(self, v):
- pass
-
- def throw(self, *exc):
- pass
-
- def close(self):
- pass
-
- def __await__(self):
- pass
-
- coro = Coro()
+ coro = CoroLike()
coro.__name__ = 'AAA'
self.assertTrue(asyncio.iscoroutine(coro))
self.assertEqual(coroutines._format_coroutine(coro), 'AAA()')
coro.cr_running = True
self.assertEqual(coroutines._format_coroutine(coro), 'BBB() running')
- coro = Coro()
+ coro = CoroLike()
# Some coroutines might not have '__name__', such as
# built-in async_gen.asend().
- self.assertEqual(coroutines._format_coroutine(coro), 'Coro()')
+ self.assertEqual(coroutines._format_coroutine(coro), 'CoroLike()')
class TimerTests(unittest.TestCase):
from test.test_asyncio import utils as test_utils
+# Test that asyncio.iscoroutine() uses collections.abc.Coroutine
+class FakeCoro:
+ def send(self, value):
+ pass
+
+ def throw(self, typ, val=None, tb=None):
+ pass
+
+ def close(self):
+ pass
+
+ def __await__(self):
+ yield
+
+
class BaseTest(test_utils.TestCase):
def setUp(self):
finally:
f.close() # silence warning
- # Test that asyncio.iscoroutine() uses collections.abc.Coroutine
- class FakeCoro:
- def send(self, value): pass
- def throw(self, typ, val=None, tb=None): pass
- def close(self): pass
- def __await__(self): yield
-
self.assertTrue(asyncio.iscoroutine(FakeCoro()))
def test_iscoroutinefunction(self):