mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Issue #26136: Upgrade the generator_stop warning to DeprecationWarning
Patch by Anish Shah.
This commit is contained in:
parent
b0cb42dfdb
commit
7e3a91a5fc
6 changed files with 19 additions and 7 deletions
|
|
@ -89,7 +89,7 @@ class ContextManagerTestCase(unittest.TestCase):
|
|||
def woohoo():
|
||||
yield
|
||||
try:
|
||||
with self.assertWarnsRegex(PendingDeprecationWarning,
|
||||
with self.assertWarnsRegex(DeprecationWarning,
|
||||
"StopIteration"):
|
||||
with woohoo():
|
||||
raise stop_exc
|
||||
|
|
|
|||
|
|
@ -245,11 +245,11 @@ class ExceptionTest(unittest.TestCase):
|
|||
yield
|
||||
|
||||
with self.assertRaises(StopIteration), \
|
||||
self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
|
||||
self.assertWarnsRegex(DeprecationWarning, "StopIteration"):
|
||||
|
||||
next(gen())
|
||||
|
||||
with self.assertRaisesRegex(PendingDeprecationWarning,
|
||||
with self.assertRaisesRegex(DeprecationWarning,
|
||||
"generator .* raised StopIteration"), \
|
||||
warnings.catch_warnings():
|
||||
|
||||
|
|
@ -268,7 +268,7 @@ class ExceptionTest(unittest.TestCase):
|
|||
g = f()
|
||||
self.assertEqual(next(g), 1)
|
||||
|
||||
with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
|
||||
with self.assertWarnsRegex(DeprecationWarning, "StopIteration"):
|
||||
with self.assertRaises(StopIteration):
|
||||
next(g)
|
||||
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
|
|||
with cm():
|
||||
raise StopIteration("from with")
|
||||
|
||||
with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
|
||||
with self.assertWarnsRegex(DeprecationWarning, "StopIteration"):
|
||||
self.assertRaises(StopIteration, shouldThrow)
|
||||
|
||||
def testRaisedStopIteration2(self):
|
||||
|
|
@ -482,7 +482,7 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
|
|||
with cm():
|
||||
raise next(iter([]))
|
||||
|
||||
with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
|
||||
with self.assertWarnsRegex(DeprecationWarning, "StopIteration"):
|
||||
self.assertRaises(StopIteration, shouldThrow)
|
||||
|
||||
def testRaisedGeneratorExit1(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue