def test_template_hook_collect(self): def func(context, *args, **kwargs): self.assertEqual(context, "context") self.assertEqual(args, ("foo", )) self.assertEqual(kwargs, {'extra': "bar", }) return "hello" utils_hooks.myhook.register(func) res = template_hook_collect(utils_hooks, 'myhook', "context", "foo", extra="bar") self.assertEqual(res, u"hello") res = template_hook_collect(utils_hooks, 'badhook') self.assertEqual(res, u"")
def test_template_hook_collect(self): def func(context, *args, **kwargs): self.assertEqual(context, "context") self.assertEqual(args, ("foo",)) self.assertEqual(kwargs, {"extra": "bar"}) return "hello" utils_hooks.myhook.register(func) res = template_hook_collect(utils_hooks, "myhook", "context", "foo", extra="bar") self.assertEqual(res, "hello") res = template_hook_collect(utils_hooks, "badhook") self.assertEqual(res, "")
def test_template_hook_collect_escaped(self): def func(*args, **kwargs): return "<span>hello</span>" utils_hooks.myhook.register(func) res = template_hook_collect(utils_hooks, 'myhook', "context", "foo", extra="bar") self.assertEqual(res, "<span>hello</span>")
def test_template_hook_collect_escaped(self): def func(*args, **kwargs): return "<span>hello</span>" utils_hooks.myhook.register(func) res = template_hook_collect(utils_hooks, "myhook", "context", "foo", extra="bar") self.assertEqual(res, "<span>hello</span>")