diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_generators.py | 22 | ||||
-rw-r--r-- | Lib/test/test_with.py | 11 |
2 files changed, 9 insertions, 24 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): diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py index c70f6859b4..b1d7a15b5e 100644 --- a/Lib/test/test_with.py +++ b/Lib/test/test_with.py @@ -458,8 +458,8 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase): with cm(): raise StopIteration("from with") - with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): - self.assertRaises(StopIteration, shouldThrow) + with self.assertRaisesRegex(StopIteration, 'from with'): + shouldThrow() def testRaisedStopIteration2(self): # From bug 1462485 @@ -473,7 +473,8 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase): with cm(): raise StopIteration("from with") - self.assertRaises(StopIteration, shouldThrow) + with self.assertRaisesRegex(StopIteration, 'from with'): + shouldThrow() def testRaisedStopIteration3(self): # Another variant where the exception hasn't been instantiated @@ -486,8 +487,8 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase): with cm(): raise next(iter([])) - with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): - self.assertRaises(StopIteration, shouldThrow) + with self.assertRaises(StopIteration): + shouldThrow() def testRaisedGeneratorExit1(self): # From bug 1462485 |