diff options
author | Thomas Grainger <tagrain@gmail.com> | 2021-07-20 18:15:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 18:15:07 (GMT) |
commit | 7f1c330da31c54e028dceaf3610877914c2a4497 (patch) | |
tree | 300b1b0e55088dc48f76bc11a5f2799a66936115 /Lib/test/test_contextlib.py | |
parent | 85fa3b6b7c11897732fedc443db0e4e8e380c8f8 (diff) | |
download | cpython-7f1c330da31c54e028dceaf3610877914c2a4497.zip cpython-7f1c330da31c54e028dceaf3610877914c2a4497.tar.gz cpython-7f1c330da31c54e028dceaf3610877914c2a4497.tar.bz2 |
bpo-44566: resolve differences between asynccontextmanager and contextmanager (#27024)
Diffstat (limited to 'Lib/test/test_contextlib.py')
-rw-r--r-- | Lib/test/test_contextlib.py | 23 |
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 = """\ |