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

Method test_async_contextmanager

Lib/test/test_typing.py:8003–8018  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

8001 self.assertEqual(get_args(gen_cm.__value__[int, None]), (int, types.NoneType))
8002
8003 def test_async_contextmanager(self):
8004 class NotACM:
8005 pass
8006 self.assertIsInstance(ACM(), typing.AsyncContextManager)
8007 self.assertNotIsInstance(NotACM(), typing.AsyncContextManager)
8008 @contextlib.contextmanager
8009 def manager():
8010 yield 42
8011
8012 cm = manager()
8013 self.assertNotIsInstance(cm, typing.AsyncContextManager)
8014 self.assertEqual(typing.AsyncContextManager[int].__args__, (int, bool | None))
8015 with self.assertRaises(TypeError):
8016 isinstance(42, typing.AsyncContextManager[int])
8017 with self.assertRaises(TypeError):
8018 typing.AsyncContextManager[int, str, float]
8019
8020 def test_asynccontextmanager_type_params(self):
8021 cm1 = typing.AsyncContextManager[int]

Callers

nothing calls this directly

Calls 7

ACMClass · 0.85
NotACMClass · 0.85
managerClass · 0.85
assertIsInstanceMethod · 0.80
assertNotIsInstanceMethod · 0.80
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected