Esempio n. 1
0
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
Esempio n. 2
0
def test_hooks_is_barely_instantiable():
    actual = Hooks().__class__
    assert actual == Hooks
Esempio n. 3
0
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
Esempio n. 4
0
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