def deactivate(self, plugin): """ Deactivates a plugin, unregistering all of its hook callbacks :param plugin: either a plugin object or a plugin name """ plugin = self._get_installed_plugin(plugin) plugin_name = plugin.get_name() if plugin_name in self._active: gossip.get_global_group().unregister_token(self._get_token(plugin_name)) self._active.discard(plugin_name) plugin.deactivate()
def deactivate(self, plugin): """ Deactivates a plugin, unregistering all of its hook callbacks :param plugin: either a plugin object or a plugin name """ plugin = self._get_installed_plugin(plugin) plugin_name = plugin.get_name() token = self._get_token(plugin_name) if plugin_name in self._active: gossip.get_global_group().unregister_token(token) self._active.discard(plugin_name) plugin.deactivate()
def test_global_group_is_same(registered_hooks): # pylint: disable=unused-argument global_group = gossip.get_global_group() global_group.reset() assert gossip.get_global_group() is global_group
def test_get_exception_policy(exception_handling_policy): group = gossip.groups.Group("some_group", parent=gossip.get_global_group()) group.set_exception_policy(exception_handling_policy) assert group.get_exception_policy() is exception_handling_policy
def test_global_group_reset_delets_all_group(registered_hooks): assert gossip.get_groups() gossip.get_global_group().reset() assert not gossip.get_groups() assert all(not r.works() for r in registered_hooks) assert not gossip.get_global_group().get_subgroups()
def test_default_global_group_policy(): assert isinstance(gossip.get_global_group().get_exception_policy(), gossip.RaiseImmediately)
def test_group_returns_to_default_after_reset(): gossip.get_global_group().set_exception_policy(gossip.IgnoreExceptions()) gossip.get_global_group().reset() test_default_global_group_policy()
def test_policy_gets_reset(): gossip.get_global_group().set_unconstrained_handler_priority(gossip.FIRST) gossip.get_global_group().reset() assert gossip.get_global_group().get_unconstrained_handler_priority( ) == gossip.DONT_CARE
def test_hook_str_repr(stringify): assert stringify(Hook(get_global_group(), "some_name", arg_names=("a", "b"))) == \ "<Hook some_name(a, b)>"
def undefine_all(): gossip.get_global_group().reset()
def test_policy_gets_reset(): gossip.get_global_group().set_unconstrained_handler_priority(gossip.FIRST) gossip.get_global_group().reset() assert gossip.get_global_group().get_unconstrained_handler_priority() == gossip.DONT_CARE
def test_default_global_group_policy(): assert isinstance(gossip.get_global_group() .get_exception_policy(), gossip.RaiseImmediately)