Exemple #1
0
    def test_hooks_extra_plugins(self):
        registry = Registry()

        class Api:
            def hello(self, arg):
                pass

        hookrelay = HookRelay(hookspecs=Api, registry=registry)
        hook_hello = hookrelay.hello

        class Plugin:
            def hello(self, arg):
                return arg + 1

        registry.register(Plugin())

        class Plugin2:
            def hello(self, arg):
                return arg + 2

        newhook = hookrelay._makecall("hello", extralookup=Plugin2())
        l = newhook(arg=3)
        assert l == [5, 4]
        l2 = hook_hello(arg=3)
        assert l2 == [4]
Exemple #2
0
 def test_hooks_extra_plugins(self):
     registry = Registry()
     class Api:
         def hello(self, arg):
             pass
     hookrelay = HookRelay(hookspecs=Api, registry=registry)
     hook_hello = hookrelay.hello
     class Plugin:
         def hello(self, arg):
             return arg + 1
     registry.register(Plugin())
     class Plugin2:
         def hello(self, arg):
             return arg + 2
     newhook = hookrelay._makecall("hello", extralookup=Plugin2())
     l = newhook(arg=3)
     assert l == [5, 4]
     l2 = hook_hello(arg=3)
     assert l2 == [4]