MCPcopy Index your code
hub / github.com/python/cpython / test_isawaitable

Method test_isawaitable

Lib/test/test_inspect/test_inspect.py:392–413  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

390 coro.close(); gen_coro.close(); # silence warnings
391
392 def test_isawaitable(self):
393 def gen(): yield
394 self.assertFalse(inspect.isawaitable(gen()))
395
396 coro = coroutine_function_example(1)
397 gen_coro = gen_coroutine_function_example(1)
398
399 self.assertTrue(inspect.isawaitable(coro))
400 self.assertTrue(inspect.isawaitable(gen_coro))
401
402 class Future:
403 def __await__():
404 pass
405 self.assertTrue(inspect.isawaitable(Future()))
406 self.assertFalse(inspect.isawaitable(Future))
407
408 class NotFuture: pass
409 not_fut = NotFuture()
410 not_fut.__await__ = lambda: None
411 self.assertFalse(inspect.isawaitable(not_fut))
412
413 coro.close(); gen_coro.close() # silence warnings
414
415 def test_isroutine(self):
416 # method

Callers

nothing calls this directly

Calls 8

NotFutureClass · 0.85
assertFalseMethod · 0.80
assertTrueMethod · 0.80
FutureClass · 0.70
genFunction · 0.50
closeMethod · 0.45

Tested by

no test coverage detected