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

Method test_exception_function

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

Source from the content-addressed store, hash-verified

377
378 # Test exception propagation through function iterator
379 def test_exception_function(self):
380 def spam(state=[0]):
381 i = state[0]
382 state[0] = i+1
383 if i == 10:
384 raise RuntimeError
385 return i
386 res = []
387 try:
388 for x in iter(spam, 20):
389 res.append(x)
390 except RuntimeError:
391 self.assertEqual(res, list(range(10)))
392 else:
393 self.fail("should have raised RuntimeError")
394
395 # Test exception propagation through sequence iterator
396 def test_exception_sequence(self):

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected