Skip to content

Commit 8c38bd5

Browse files
committed
pythongh-91051: fix type watcher test to be robust to existing watcher
1 parent bb456a0 commit 8c38bd5

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+
while True:
357+
stack.enter_context(self.watcher())
360358

361359

362360
class TestCodeObjectWatchers(unittest.TestCase):

0 commit comments

Comments
 (0)