def test_hooks_can_be_mass_registered(): class MyHooks: def inbound_early(self, x): return x def outbound_late(self, x): return x + xx hooks = Hooks(["inbound_early", "inbound_late", "outbound_early", "outbound_late"]) myhooks = MyHooks() hooks.register(myhooks) assert myhooks.inbound_early in hooks.inbound_early assert hooks.inbound_late == [] assert hooks.outbound_early == [] assert myhooks.outbound_late in hooks.outbound_late
def test_hooks_is_barely_instantiable(): actual = Hooks().__class__ assert actual == Hooks
def test_hooks_can_Be_run(): hooks = Hooks() thing = object() hooks.yeah_hook = [lambda thing: thing] actual = hooks.run('yeah_hook', thing) assert actual is thing
def test_hooks_can_Be_run(): hooks = Hooks() thing = object() hooks.yeah_hook = [lambda thing: thing] actual = hooks.run('yeah_hook', thing) assert actual is thing, actual