Exemple #1
0
    def test_firstresult_definition(self):
        pm = PluginManager()
        class Api:
            def hello(self, arg):
                "api hook 1"
            hello.firstresult = True

        mcm = HookRelay(hookspecs=Api, pm=pm, prefix="he")
        class Plugin:
            def hello(self, arg):
                return arg + 1
        pm.register(Plugin())
        res = mcm.hello(arg=3)
        assert res == 4
Exemple #2
0
    def test_happypath(self):
        pm = PluginManager()
        class Api:
            def hello(self, arg):
                "api hook 1"

        mcm = HookRelay(hookspecs=Api, pm=pm, prefix="he")
        assert hasattr(mcm, 'hello')
        assert repr(mcm.hello).find("hello") != -1
        class Plugin:
            def hello(self, arg):
                return arg + 1
        pm.register(Plugin())
        l = mcm.hello(arg=3)
        assert l == [4]
        assert not hasattr(mcm, 'world')
Exemple #3
0
    def test_firstresult_definition(self):
        pm = PluginManager()

        class Api:
            def hello(self, arg):
                "api hook 1"

            hello.firstresult = True

        mcm = HookRelay(hookspecs=Api, pm=pm, prefix="he")

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

        pm.register(Plugin())
        res = mcm.hello(arg=3)
        assert res == 4
Exemple #4
0
    def test_happypath(self):
        pm = PluginManager()

        class Api:
            def hello(self, arg):
                "api hook 1"

        mcm = HookRelay(hookspecs=Api, pm=pm, prefix="he")
        assert hasattr(mcm, 'hello')
        assert repr(mcm.hello).find("hello") != -1

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

        pm.register(Plugin())
        l = mcm.hello(arg=3)
        assert l == [4]
        assert not hasattr(mcm, 'world')