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