summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_monitoring.py
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2023-09-18 14:30:08 (GMT)
committerGitHub <noreply@github.com>2023-09-18 14:30:08 (GMT)
commit412f5e85d6b9f2e90c57c54539d06c7a025a472a (patch)
tree83ad67b4151ed3b06455d85f03fe84858b5b1bdb /Lib/test/test_monitoring.py
parent23f9f6f46454455bc6015e83ae5b5e946dae7698 (diff)
downloadcpython-412f5e85d6b9f2e90c57c54539d06c7a025a472a.zip
cpython-412f5e85d6b9f2e90c57c54539d06c7a025a472a.tar.gz
cpython-412f5e85d6b9f2e90c57c54539d06c7a025a472a.tar.bz2
gh-109371: Fix monitoring with instruction events set (gh-109385)
Diffstat (limited to 'Lib/test/test_monitoring.py')
-rw-r--r--Lib/test/test_monitoring.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py
index 992d3cc..2100d99 100644
--- a/Lib/test/test_monitoring.py
+++ b/Lib/test/test_monitoring.py
@@ -501,6 +501,22 @@ class MultipleMonitorsTest(MonitoringTestBase, unittest.TestCase):
self.assertEqual(sys.monitoring._all_events(), {})
sys.monitoring.restart_events()
+ def test_with_instruction_event(self):
+ """Test that the second tool can set events with instruction events set by the first tool."""
+ def f():
+ pass
+ code = f.__code__
+
+ try:
+ self.assertEqual(sys.monitoring._all_events(), {})
+ sys.monitoring.set_local_events(TEST_TOOL, code, E.INSTRUCTION | E.LINE)
+ sys.monitoring.set_local_events(TEST_TOOL2, code, E.LINE)
+ finally:
+ sys.monitoring.set_events(TEST_TOOL, 0)
+ sys.monitoring.set_events(TEST_TOOL2, 0)
+ self.assertEqual(sys.monitoring._all_events(), {})
+
+
class LineMonitoringTest(MonitoringTestBase, unittest.TestCase):
def test_lines_single(self):