Skip to content

Commit fce93c8

Browse files
authoredAug 16, 2023
gh-91051: fix type watcher test to be robust to existing watcher (#107989)
1 parent 8891a88 commit fce93c8

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)