Lines Matching full:hook
14 """Used in standard hook tests to collect any logged events.
83 with TestHook() as hook:
85 assertEqual(hook.seen[0][0], "test_event")
86 assertEqual(hook.seen[0][1], (1, 2, 3))
90 # Raising an exception should prevent a new hook from being added,
100 # Raising BaseException will propagate out when adding a hook
105 # Adding this next hook should raise BaseException
115 with TestHook() as hook:
126 actual = [(a[0], a[1]) for e, a in hook.seen if e == "marshal.dumps"]
129 actual = [a[0] for e, a in hook.seen if e == "marshal.loads"]
132 actual = [e for e, a in hook.seen if e == "marshal.load"]
146 # Before we add the hook, ensure our malicious pickle loads
149 with TestHook(raise_on_events="pickle.find_class") as hook:
151 # With the hook enabled, loading globals is not allowed
169 with TestHook() as hook:
183 actual = [(a[0], a[1]) for e, a in hook.seen if e == "object.__setattr__"]
200 with TestHook(raise_on_events={"open"}) as hook:
213 actual_mode = [(a[0], a[1]) for e, a in hook.seen if e == "open" and a[1]]
214 actual_flag = [(a[0], a[2]) for e, a in hook.seen if e == "open" and not a[1]]
241 with TestHook() as hook:
246 hook.__cantrace__ = False
250 hook.__cantrace__ = True
254 hook.__cantrace__ = 1
258 hook.__cantrace__ = 0
268 with TestHook() as hook:
270 assertEqual(hook.seen[0][1][:2], (-1, 8))
278 def hook(event, args): function
286 sys.addaudithook(hook)
297 def hook(event, args): function
303 sys.addaudithook(hook)
306 "Exception ignored for audit hook test")
312 def hook(event, args): function
317 sys.addaudithook(hook)
335 def hook(event, args): function
339 sys.addaudithook(hook)
357 def hook(event, args): function
361 sys.addaudithook(hook)
375 def hook(event, args): function
379 sys.addaudithook(hook)
393 def hook(event, *args): function
397 sys.addaudithook(hook)
418 def hook(event, args): function
422 sys.addaudithook(hook)
429 def hook(event, args): function
433 sys.addaudithook(hook)
440 def hook(event, args): function
444 sys.addaudithook(hook)
469 def hook(event, args): function
473 sys.addaudithook(hook)
485 def hook(event, args): function
489 sys.addaudithook(hook)
501 def hook(event, args): function
505 sys.addaudithook(hook)
522 hook = lambda *a: None function
523 sys.addaudithook(hook)
527 assert hook not in o
533 def hook(event, args): function
538 raise AssertionError('hook failed')
539 sys.addaudithook(hook)
551 def hook(event, args): function
555 sys.addaudithook(hook)
562 def hook(event, args): function
566 sys.addaudithook(hook)