mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-32670: Enforce PEP 479. (#5327)
This commit is contained in:
parent
dba976b8a2
commit
43c47fe096
7 changed files with 38 additions and 80 deletions
|
@ -265,26 +265,16 @@ class ExceptionTest(unittest.TestCase):
|
|||
self.assertEqual(next(g), "done")
|
||||
self.assertEqual(sys.exc_info(), (None, None, None))
|
||||
|
||||
def test_stopiteration_warning(self):
|
||||
def test_stopiteration_error(self):
|
||||
# See also PEP 479.
|
||||
|
||||
def gen():
|
||||
raise StopIteration
|
||||
yield
|
||||
|
||||
with self.assertRaises(StopIteration), \
|
||||
self.assertWarnsRegex(DeprecationWarning, "StopIteration"):
|
||||
|
||||
with self.assertRaisesRegex(RuntimeError, 'raised StopIteration'):
|
||||
next(gen())
|
||||
|
||||
with self.assertRaisesRegex(DeprecationWarning,
|
||||
"generator .* raised StopIteration"), \
|
||||
warnings.catch_warnings():
|
||||
|
||||
warnings.simplefilter('error')
|
||||
next(gen())
|
||||
|
||||
|
||||
def test_tutorial_stopiteration(self):
|
||||
# Raise StopIteration" stops the generator too:
|
||||
|
||||
|
@ -296,13 +286,7 @@ class ExceptionTest(unittest.TestCase):
|
|||
g = f()
|
||||
self.assertEqual(next(g), 1)
|
||||
|
||||
with self.assertWarnsRegex(DeprecationWarning, "StopIteration"):
|
||||
with self.assertRaises(StopIteration):
|
||||
next(g)
|
||||
|
||||
with self.assertRaises(StopIteration):
|
||||
# This time StopIteration isn't raised from the generator's body,
|
||||
# hence no warning.
|
||||
with self.assertRaisesRegex(RuntimeError, 'raised StopIteration'):
|
||||
next(g)
|
||||
|
||||
def test_return_tuple(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue