diff options
author | Tian Gao <gaogaotiantian@hotmail.com> | 2023-09-13 08:47:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-13 08:47:35 (GMT) |
commit | d69805b38a1815e7aaadf49bdd019c7cca105ac6 (patch) | |
tree | d57297e29dc64b91274b5d081b77c870825bfe90 /Lib/test/test_monitoring.py | |
parent | a0c06a4f933faccd7f8201701b2491d38464212c (diff) | |
download | cpython-d69805b38a1815e7aaadf49bdd019c7cca105ac6.zip cpython-d69805b38a1815e7aaadf49bdd019c7cca105ac6.tar.gz cpython-d69805b38a1815e7aaadf49bdd019c7cca105ac6.tar.bz2 |
gh-109156: Add tests for de-instrumenting instructions with instrumented lines (GH-109157)
Diffstat (limited to 'Lib/test/test_monitoring.py')
-rw-r--r-- | Lib/test/test_monitoring.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py index 575862b..992d3cc 100644 --- a/Lib/test/test_monitoring.py +++ b/Lib/test/test_monitoring.py @@ -1152,6 +1152,23 @@ class TestLineAndInstructionEvents(CheckEvents): ('instruction', 'func1', 14), ('line', 'get_events', 11)]) + def test_turn_off_only_instruction(self): + """ + LINE events should be recorded after INSTRUCTION event is turned off + """ + events = [] + def line(*args): + events.append("line") + sys.monitoring.set_events(TEST_TOOL, 0) + sys.monitoring.register_callback(TEST_TOOL, E.LINE, line) + sys.monitoring.register_callback(TEST_TOOL, E.INSTRUCTION, lambda *args: None) + sys.monitoring.set_events(TEST_TOOL, E.LINE | E.INSTRUCTION) + sys.monitoring.set_events(TEST_TOOL, E.LINE) + events = [] + a = 0 + sys.monitoring.set_events(TEST_TOOL, 0) + self.assertGreater(len(events), 0) + class TestInstallIncrementallly(MonitoringTestBase, unittest.TestCase): def check_events(self, func, must_include, tool=TEST_TOOL, recorders=(ExceptionRecorder,)): |