diff options
author | Steve Dower <steve.dower@python.org> | 2019-12-09 11:18:12 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-09 11:18:12 -0800 |
commit | ee17e3735634c5fe15a43f897707de8011618627 (patch) | |
tree | b3873444a813a981b82be2a47c26a3545bf6cd00 /Lib/test/audit-tests.py | |
parent | b8cbe74c3498c617f0e73fd0cdc5c07f2c532092 (diff) | |
download | cpython-git-ee17e3735634c5fe15a43f897707de8011618627.tar.gz |
bpo-39007: Add auditing events to functions in winreg (GH-17541)
Also allows winreg.CloseKey() to accept same types as other functions.
Diffstat (limited to 'Lib/test/audit-tests.py')
-rw-r--r-- | Lib/test/audit-tests.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/audit-tests.py b/Lib/test/audit-tests.py index ed08612c04..33f320992b 100644 --- a/Lib/test/audit-tests.py +++ b/Lib/test/audit-tests.py @@ -304,6 +304,29 @@ def test_unraisablehook(): write_unraisable_exc(RuntimeError("nonfatal-error"), "for audit hook test", None) +def test_winreg(): + from winreg import OpenKey, EnumKey, CloseKey, HKEY_LOCAL_MACHINE + + def hook(event, args): + if not event.startswith("winreg."): + return + print(event, *args) + + sys.addaudithook(hook) + + k = OpenKey(HKEY_LOCAL_MACHINE, "Software") + EnumKey(k, 0) + try: + EnumKey(k, 10000) + except OSError: + pass + else: + raise RuntimeError("Expected EnumKey(HKLM, 10000) to fail") + + kv = k.Detach() + CloseKey(kv) + + if __name__ == "__main__": from test.libregrtest.setup import suppress_msvcrt_asserts |