diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_with.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py index a7bc206..e778463 100644 --- a/Lib/test/test_with.py +++ b/Lib/test/test_with.py @@ -442,6 +442,7 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase): self.assertAfterWithGeneratorInvariantsNoError(self.bar) def testRaisedStopIteration1(self): + # From bug 1462485 @contextmanager def cm(): yield @@ -453,6 +454,7 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase): self.assertRaises(StopIteration, shouldThrow) def testRaisedStopIteration2(self): + # From bug 1462485 class cm(object): def __enter__(self): pass @@ -465,7 +467,21 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase): self.assertRaises(StopIteration, shouldThrow) + def testRaisedStopIteration3(self): + # Another variant where the exception hasn't been instantiated + # From bug 1705170 + @contextmanager + def cm(): + yield + + def shouldThrow(): + with cm(): + raise next(iter([])) + + self.assertRaises(StopIteration, shouldThrow) + def testRaisedGeneratorExit1(self): + # From bug 1462485 @contextmanager def cm(): yield @@ -477,6 +493,7 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase): self.assertRaises(GeneratorExit, shouldThrow) def testRaisedGeneratorExit2(self): + # From bug 1462485 class cm (object): def __enter__(self): pass |