Skip to content

Commit

Permalink
[3.12] gh-91051: fix type watcher test to be robust to existing watch…
Browse files Browse the repository at this point in the history
…er (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 <carl@oddbird.net>
  • Loading branch information
miss-islington and carljm committed Aug 16, 2023
1 parent 6bab8ef commit 84a4370
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Lib/test/test_capi/test_watchers.py
Expand Up @@ -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):
Expand Down

0 comments on commit 84a4370

Please sign in to comment.