summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_contextlib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_contextlib.py')
-rw-r--r--Lib/test/test_contextlib.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index 9c27866..04720d9 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -126,19 +126,22 @@ class ContextManagerTestCase(unittest.TestCase):
self.assertEqual(state, [1, 42, 999])
def test_contextmanager_except_stopiter(self):
- stop_exc = StopIteration('spam')
@contextmanager
def woohoo():
yield
- try:
- with self.assertWarnsRegex(DeprecationWarning,
- "StopIteration"):
- with woohoo():
- raise stop_exc
- except Exception as ex:
- self.assertIs(ex, stop_exc)
- else:
- self.fail('StopIteration was suppressed')
+
+ class StopIterationSubclass(StopIteration):
+ pass
+
+ for stop_exc in (StopIteration('spam'), StopIterationSubclass('spam')):
+ with self.subTest(type=type(stop_exc)):
+ try:
+ with woohoo():
+ raise stop_exc
+ except Exception as ex:
+ self.assertIs(ex, stop_exc)
+ else:
+ self.fail(f'{stop_exc} was suppressed')
def test_contextmanager_except_pep479(self):
code = """\