(self)
| 464 | self.assertIsNone(sys.exception()) |
| 465 | |
| 466 | def test_except_gen_except(self): |
| 467 | def gen(): |
| 468 | try: |
| 469 | self.assertIsNone(sys.exception()) |
| 470 | yield |
| 471 | # we are called from "except ValueError:", TypeError must |
| 472 | # inherit ValueError in its context |
| 473 | raise TypeError() |
| 474 | except TypeError as exc: |
| 475 | self.assertIsInstance(sys.exception(), TypeError) |
| 476 | self.assertEqual(type(exc.__context__), ValueError) |
| 477 | # here we are still called from the "except ValueError:" |
| 478 | self.assertIsInstance(sys.exception(), ValueError) |
| 479 | yield |
| 480 | self.assertIsNone(sys.exception()) |
| 481 | yield "done" |
| 482 | |
| 483 | g = gen() |
| 484 | next(g) |
| 485 | try: |
| 486 | raise ValueError |
| 487 | except Exception: |
| 488 | next(g) |
| 489 | |
| 490 | self.assertEqual(next(g), "done") |
| 491 | self.assertIsNone(sys.exception()) |
| 492 | |
| 493 | def test_nested_gen_except_loop(self): |
| 494 | def gen(): |
nothing calls this directly
no test coverage detected