[Python-checkins] [3.12] gh-91051: fix type watcher test to be robust to existing watcher (GH-107989) (#108053)
Yhg1s
webhook-mailer at python.org
Wed Aug 16 19:18:27 EDT 2023
https://github.com/python/cpython/commit/84a4370e31632fb04590131ed24329c60cf2f356
commit: 84a4370e31632fb04590131ed24329c60cf2f356
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Yhg1s <thomas at python.org>
date: 2023-08-17T01:18:24+02:00
summary:
[3.12] gh-91051: fix type watcher test to be robust to existing watcher (GH-107989) (#108053)
gh-91051: fix type watcher test to be robust to existing watcher (GH-107989)
(cherry picked from commit fce93c80ae2d792b8ca443b044e28abbf28bb89a)
Co-authored-by: Carl Meyer <carl at oddbird.net>
files:
M Lib/test/test_capi/test_watchers.py
diff --git a/Lib/test/test_capi/test_watchers.py b/Lib/test/test_capi/test_watchers.py
index 10b76e163bfb2..6b8855ec219d2 100644
--- a/Lib/test/test_capi/test_watchers.py
+++ b/Lib/test/test_capi/test_watchers.py
@@ -351,12 +351,10 @@ def test_clear_unassigned_watcher_id(self):
self.clear_watcher(1)
def test_no_more_ids_available(self):
- contexts = [self.watcher() for i in range(self.TYPE_MAX_WATCHERS)]
- with ExitStack() as stack:
- for ctx in contexts:
- stack.enter_context(ctx)
- with self.assertRaisesRegex(RuntimeError, r"no more type watcher IDs"):
- self.add_watcher()
+ with self.assertRaisesRegex(RuntimeError, r"no more type watcher IDs"):
+ with ExitStack() as stack:
+ for _ in range(self.TYPE_MAX_WATCHERS + 1):
+ stack.enter_context(self.watcher())
class TestCodeObjectWatchers(unittest.TestCase):
More information about the Python-checkins
mailing list