MCPcopy Create free account
hub / github.com/RustPython/RustPython / test_async_contextmanager

Method test_async_contextmanager

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

Source from the content-addressed store, hash-verified

7920 self.assertEqual(get_args(gen_cm.__value__[int, None]), (int, types.NoneType))
7921
7922 def test_async_contextmanager(self):
7923 class NotACM:
7924 pass
7925 self.assertIsInstance(ACM(), typing.AsyncContextManager)
7926 self.assertNotIsInstance(NotACM(), typing.AsyncContextManager)
7927 @contextlib.contextmanager
7928 def manager():
7929 yield 42
7930
7931 cm = manager()
7932 self.assertNotIsInstance(cm, typing.AsyncContextManager)
7933 self.assertEqual(typing.AsyncContextManager[int].__args__, (int, bool | None))
7934 with self.assertRaises(TypeError):
7935 isinstance(42, typing.AsyncContextManager[int])
7936 with self.assertRaises(TypeError):
7937 typing.AsyncContextManager[int, str, float]
7938
7939 def test_asynccontextmanager_type_params(self):
7940 cm1 = typing.AsyncContextManager[int]

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected