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

Class SeqWithWeirdLen

Lib/test/test_enumerate.py:204–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202 list(r)
203 self.assertEqual(operator.length_hint(r), 0)
204 class SeqWithWeirdLen:
205 called = False
206 def __len__(self):
207 if not self.called:
208 self.called = True
209 return 10
210 raise ZeroDivisionError
211 def __getitem__(self, index):
212 return index
213 r = reversed(SeqWithWeirdLen())
214 self.assertRaises(ZeroDivisionError, operator.length_hint, r)
215

Callers 1

test_lenMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_lenMethod · 0.68