summaryrefslogtreecommitdiff
path: root/Lib/test/test_generators.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_generators.py')
-rw-r--r--Lib/test/test_generators.py22
1 files changed, 3 insertions, 19 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index bd17ad4a21..3461f203de 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -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"):
-
- next(gen())
-
- with self.assertRaisesRegex(DeprecationWarning,
- "generator .* raised StopIteration"), \
- warnings.catch_warnings():
-
- warnings.simplefilter('error')
+ with self.assertRaisesRegex(RuntimeError, 'raised StopIteration'):
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):