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

Method test_AsyncIterator

Lib/test/test_collections.py:949–967  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

947 self.validate_isinstance(AsyncIterable, '__aiter__')
948
949 def test_AsyncIterator(self):
950 class AI:
951 def __aiter__(self):
952 return self
953 async def __anext__(self):
954 raise StopAsyncIteration
955 self.assertIsInstance(AI(), AsyncIterator)
956 self.assertIsSubclass(AI, AsyncIterator)
957 non_samples = [None, object, []]
958 # Check some non-iterables
959 for x in non_samples:
960 self.assertNotIsInstance(x, AsyncIterator)
961 self.assertNotIsSubclass(type(x), AsyncIterator)
962 # Similarly to regular iterators (see issue 10565)
963 class AnextOnly:
964 async def __anext__(self):
965 raise StopAsyncIteration
966 self.assertNotIsInstance(AnextOnly(), AsyncIterator)
967 self.validate_abstract_methods(AsyncIterator, '__anext__')
968
969 def test_Iterable(self):
970 # Check some non-iterables

Callers

nothing calls this directly

Calls 7

AnextOnlyClass · 0.85
assertIsInstanceMethod · 0.80
assertIsSubclassMethod · 0.80
assertNotIsInstanceMethod · 0.80
assertNotIsSubclassMethod · 0.80
AIClass · 0.70

Tested by

no test coverage detected