MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_Iterator

Method test_Iterator

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

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

Tested by

no test coverage detected