From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 13 Sep 2023 10:36:30 +0000 (-0700) Subject: [3.12] gh-109357: Fix test_monitoring.test_gh108976() (GH-109358) (#109359) X-Git-Tag: v3.12.0rc3~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3d8e4d7d0c674753c45e216f5bd011ed3274dc20;p=thirdparty%2FPython%2Fcpython.git [3.12] gh-109357: Fix test_monitoring.test_gh108976() (GH-109358) (#109359) gh-109357: Fix test_monitoring.test_gh108976() (GH-109358) The test now calls free_tool_id() so it can be run multiple times in the same process. For example, the following command no longer fails: python -m test test_monitoring -R 3:3 (cherry picked from commit 388d91cd474de80355f5a8f6a26e8962813a3128) Co-authored-by: Victor Stinner --- diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py index 2e4ec244ce6f..d091572b0880 100644 --- a/Lib/test/test_monitoring.py +++ b/Lib/test/test_monitoring.py @@ -1721,6 +1721,7 @@ class TestRegressions(MonitoringTestBase, unittest.TestCase): def test_gh108976(self): sys.monitoring.use_tool_id(0, "test") + self.addCleanup(sys.monitoring.free_tool_id, 0) sys.monitoring.set_events(0, 0) sys.monitoring.register_callback(0, E.LINE, lambda *args: sys.monitoring.set_events(0, 0)) sys.monitoring.register_callback(0, E.INSTRUCTION, lambda *args: 0)