summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2023-08-16 19:13:32 (GMT)
committerGitHub <noreply@github.com>2023-08-16 19:13:32 (GMT)
commitfce93c80ae2d792b8ca443b044e28abbf28bb89a (patch)
tree3f4cbaacb351aef540f0c43215d220c34bb5b999
parent8891a8821d5b03cd83a126fd6c02649448b18f41 (diff)
downloadcpython-fce93c80ae2d792b8ca443b044e28abbf28bb89a.zip
cpython-fce93c80ae2d792b8ca443b044e28abbf28bb89a.tar.gz
cpython-fce93c80ae2d792b8ca443b044e28abbf28bb89a.tar.bz2
gh-91051: fix type watcher test to be robust to existing watcher (#107989)
-rw-r--r--Lib/test/test_capi/test_watchers.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/Lib/test/test_capi/test_watchers.py b/Lib/test/test_capi/test_watchers.py
index 10b76e1..6b8855e 100644
--- a/Lib/test/test_capi/test_watchers.py
+++ b/Lib/test/test_capi/test_watchers.py
@@ -351,12 +351,10 @@ class TestTypeWatchers(unittest.TestCase):
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):