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

Method test_Iterator

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

Source from the content-addressed store, hash-verified

1145
1146
1147 def test_Iterator(self):
1148 non_samples = [None, 42, 3.14, 1j, b"", "", (), [], {}, set()]
1149 for x in non_samples:
1150 self.assertNotIsInstance(x, Iterator)
1151 self.assertNotIsSubclass(type(x), Iterator)
1152 samples = [iter(bytes()), iter(str()),
1153 iter(tuple()), iter(list()), iter(dict()),
1154 iter(set()), iter(frozenset()),
1155 iter(dict().keys()), iter(dict().items()),
1156 iter(dict().values()),
1157 _test_gen(),
1158 (x for x in []),
1159 ]
1160 for x in samples:
1161 self.assertIsInstance(x, Iterator)
1162 self.assertIsSubclass(type(x), Iterator)
1163 self.validate_abstract_methods(Iterator, '__next__')
1164
1165 # Issue 10565
1166 class NextOnly:
1167 def __next__(self):
1168 yield 1
1169 return
1170 self.assertNotIsInstance(NextOnly(), Iterator)
1171
1172 def test_Generator(self):
1173 class NonGen1:

Callers

nothing calls this directly

Calls 13

setFunction · 0.85
strFunction · 0.85
listClass · 0.85
_test_genFunction · 0.85
NextOnlyClass · 0.85
assertNotIsInstanceMethod · 0.80
assertNotIsSubclassMethod · 0.80
assertIsInstanceMethod · 0.80
assertIsSubclassMethod · 0.80
keysMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected