summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_with.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-05-22 15:16:47 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-05-22 15:16:47 (GMT)
commit683333955a05a31da5f0b2ca1b3bffb9962fb4b2 (patch)
tree236016d773133c19e57c14fc69144e46a586549d /Lib/test/test_with.py
parente79ec70801e410de9c3110ffe78f98e08114ae16 (diff)
downloadcpython-683333955a05a31da5f0b2ca1b3bffb9962fb4b2.zip
cpython-683333955a05a31da5f0b2ca1b3bffb9962fb4b2.tar.gz
cpython-683333955a05a31da5f0b2ca1b3bffb9962fb4b2.tar.bz2
Issue 24237: Raise PendingDeprecationWarning per PEP 479
Raise PendingDeprecationWarning when generator raises StopIteration and no __future__ import is used. Fix offenders in the stdlib and tests. See also issue 22906. Thanks to Nick Coghlan and Berker Peksag for reviews.
Diffstat (limited to 'Lib/test/test_with.py')
-rw-r--r--Lib/test/test_with.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index fcd28f6..5dbd1e6 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -454,7 +454,8 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
with cm():
raise StopIteration("from with")
- self.assertRaises(StopIteration, shouldThrow)
+ with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
+ self.assertRaises(StopIteration, shouldThrow)
def testRaisedStopIteration2(self):
# From bug 1462485
@@ -481,7 +482,8 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
with cm():
raise next(iter([]))
- self.assertRaises(StopIteration, shouldThrow)
+ with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
+ self.assertRaises(StopIteration, shouldThrow)
def testRaisedGeneratorExit1(self):
# From bug 1462485