]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-109357: Fix test_monitoring.test_gh108976() (GH-109358) (#109359)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 13 Sep 2023 10:36:30 +0000 (03:36 -0700)
committerGitHub <noreply@github.com>
Wed, 13 Sep 2023 10:36:30 +0000 (12:36 +0200)
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 <vstinner@python.org>
Lib/test/test_monitoring.py

index 2e4ec244ce6f1714ac21b067b180b314f8c42bc2..d091572b0880d60a7d3100a9e072933ffb8e2b83 100644 (file)
@@ -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)