def test_custom_hook_names(self): "Make sure that plugins with unknown hook names get discarded" class Plugin(PluginInterface): def get_name(self): return "Test plugin" def custom_hook(self): pass hooks.add_custom_hook("custom_hook") self.addCleanup(hooks.remove_custom_hook, "custom_hook") plugin = Plugin() plugins.manager.install(plugin, activate=True) self.addCleanup(plugins.manager.uninstall, plugin)
def test_custom_hook_names(request): "Make sure that plugins with unknown hook names get discarded" class Plugin(PluginInterface): def get_name(self): return "Test plugin" def custom_hook(self): pass hooks.add_custom_hook("custom_hook") @request.addfinalizer def cleanup(): # pylint: disable=unused-variable hooks.remove_custom_hook("custom_hook") plugin = Plugin() plugins.manager.install(plugin, activate=True) plugins.manager.uninstall(plugin)
def setUp(self): super(CustomHooksTest, self).setUp() self.hook_name = "some_custom_hook" self.hook = hooks.add_custom_hook(self.hook_name)
def test_cannot_install_default_hooks(self): with self.assertRaises(exceptions.HookAlreadyExists): hooks.add_custom_hook("test_start")
def test_cannot_reinstall_hook_twice(self): with self.assertRaises(exceptions.HookAlreadyExists): hooks.add_custom_hook(self.hook_name)