aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/audit-tests.py11
-rw-r--r--Lib/test/test_audit.py12
2 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/audit-tests.py b/Lib/test/audit-tests.py
index ccec9fedc44..00333cc9036 100644
--- a/Lib/test/audit-tests.py
+++ b/Lib/test/audit-tests.py
@@ -408,6 +408,17 @@ def test_sqlite3():
raise RuntimeError("Expected sqlite3.load_extension to fail")
+def test_sys_getframe():
+ import sys
+
+ def hook(event, args):
+ if event.startswith("sys."):
+ print(event, args[0].f_code.co_name)
+
+ sys.addaudithook(hook)
+ sys._getframe()
+
+
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 0fa2d74835c..6a025f39912 100644
--- a/Lib/test/test_audit.py
+++ b/Lib/test/test_audit.py
@@ -176,5 +176,17 @@ class AuditTest(unittest.TestCase):
self.assertEqual(actual, expected)
+ def test_sys_getframe(self):
+ returncode, events, stderr = self.run_python("test_sys_getframe")
+ if returncode:
+ self.fail(stderr)
+
+ if support.verbose:
+ print(*events, sep='\n')
+ actual = [(ev[0], ev[2]) for ev in events]
+ expected = [("sys._getframe", "test_sys_getframe")]
+
+ self.assertEqual(actual, expected)
+
if __name__ == "__main__":
unittest.main()