[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 fce93c80ae)

Co-authored-by: Carl Meyer <carl@oddbird.net>
This commit is contained in:
Miss Islington (bot) 2023-08-16 16:18:24 -07:00 committed by GitHub
parent 6bab8ef3ad
commit 84a4370e31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 ExitStack() as stack:
for _ in range(self.TYPE_MAX_WATCHERS + 1):
stack.enter_context(self.watcher())
class TestCodeObjectWatchers(unittest.TestCase):