Skip to content

Commit 84a4370

Browse files
[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 fce93c8) Co-authored-by: Carl Meyer <[email protected]>
1 parent 6bab8ef commit 84a4370

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Lib/test/test_capi/test_watchers.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,10 @@ def test_clear_unassigned_watcher_id(self):
351351
self.clear_watcher(1)
352352

353353
def test_no_more_ids_available(self):
354-
contexts = [self.watcher() for i in range(self.TYPE_MAX_WATCHERS)]
355-
with ExitStack() as stack:
356-
for ctx in contexts:
357-
stack.enter_context(ctx)
358-
with self.assertRaisesRegex(RuntimeError, r"no more type watcher IDs"):
359-
self.add_watcher()
354+
with self.assertRaisesRegex(RuntimeError, r"no more type watcher IDs"):
355+
with ExitStack() as stack:
356+
for _ in range(self.TYPE_MAX_WATCHERS + 1):
357+
stack.enter_context(self.watcher())
360358

361359

362360
class TestCodeObjectWatchers(unittest.TestCase):

0 commit comments

Comments
 (0)