mirror of
https://github.com/python/cpython.git
synced 2025-08-21 09:21:18 +00:00
Fix issue #1705170 (backport from trunk)
This commit is contained in:
parent
2e49f781cb
commit
e53fcfd7d3
3 changed files with 24 additions and 0 deletions
|
@ -440,6 +440,7 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
|
|||
self.assertAfterWithGeneratorInvariantsNoError(self.bar)
|
||||
|
||||
def testRaisedStopIteration1(self):
|
||||
# From bug 1462485
|
||||
@contextmanager
|
||||
def cm():
|
||||
yield
|
||||
|
@ -451,6 +452,7 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
|
|||
self.assertRaises(StopIteration, shouldThrow)
|
||||
|
||||
def testRaisedStopIteration2(self):
|
||||
# From bug 1462485
|
||||
class cm(object):
|
||||
def __enter__(self):
|
||||
pass
|
||||
|
@ -463,7 +465,21 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
|
|||
|
||||
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 iter([]).next()
|
||||
|
||||
self.assertRaises(StopIteration, shouldThrow)
|
||||
|
||||
def testRaisedGeneratorExit1(self):
|
||||
# From bug 1462485
|
||||
@contextmanager
|
||||
def cm():
|
||||
yield
|
||||
|
@ -475,6 +491,7 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
|
|||
self.assertRaises(GeneratorExit, shouldThrow)
|
||||
|
||||
def testRaisedGeneratorExit2(self):
|
||||
# From bug 1462485
|
||||
class cm (object):
|
||||
def __enter__(self):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue