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

Method test_exception_sequence

Lib/test/test_iter.py:396–409  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

394
395 # Test exception propagation through sequence iterator
396 def test_exception_sequence(self):
397 class MySequenceClass(SequenceClass):
398 def __getitem__(self, i):
399 if i == 10:
400 raise RuntimeError
401 return SequenceClass.__getitem__(self, i)
402 res = []
403 try:
404 for x in MySequenceClass(20):
405 res.append(x)
406 except RuntimeError:
407 self.assertEqual(res, list(range(10)))
408 else:
409 self.fail("should have raised RuntimeError")
410
411 # Test for StopIteration from __getitem__
412 def test_stop_sequence(self):

Callers

nothing calls this directly

Calls 5

assertEqualMethod · 0.95
failMethod · 0.95
MySequenceClassClass · 0.85
listClass · 0.85
appendMethod · 0.45

Tested by

no test coverage detected