summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/audit-tests.py11
-rw-r--r--Lib/test/test_audit.py13
2 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/audit-tests.py b/Lib/test/audit-tests.py
index 0edc9d9..9504829 100644
--- a/Lib/test/audit-tests.py
+++ b/Lib/test/audit-tests.py
@@ -514,6 +514,17 @@ def test_not_in_gc():
assert hook not in o
+def test_sys_monitoring_register_callback():
+ import sys
+
+ def hook(event, args):
+ if event.startswith("sys.monitoring"):
+ print(event, args)
+
+ sys.addaudithook(hook)
+ sys.monitoring.register_callback(1, 1, None)
+
+
if __name__ == "__main__":
from test.support import suppress_msvcrt_asserts
diff --git a/Lib/test/test_audit.py b/Lib/test/test_audit.py
index 0b69864..b12ffa5 100644
--- a/Lib/test/test_audit.py
+++ b/Lib/test/test_audit.py
@@ -257,5 +257,18 @@ class AuditTest(unittest.TestCase):
self.fail(stderr)
+ def test_sys_monitoring_register_callback(self):
+ returncode, events, stderr = self.run_python("test_sys_monitoring_register_callback")
+ if returncode:
+ self.fail(stderr)
+
+ if support.verbose:
+ print(*events, sep='\n')
+ actual = [(ev[0], ev[2]) for ev in events]
+ expected = [("sys.monitoring.register_callback", "(None,)")]
+
+ self.assertEqual(actual, expected)
+
+
if __name__ == "__main__":
unittest.main()