(self)
| 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): |
nothing calls this directly
no test coverage detected