Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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()
Ejemplo n.º 6
0
def test_default_global_group_policy():
    assert isinstance(gossip.get_global_group().get_exception_policy(),
                      gossip.RaiseImmediately)
Ejemplo n.º 7
0
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()
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
def test_hook_str_repr(stringify):
    assert stringify(Hook(get_global_group(), "some_name", arg_names=("a", "b"))) == \
        "<Hook some_name(a, b)>"
Ejemplo n.º 10
0
def undefine_all():
    gossip.get_global_group().reset()
Ejemplo n.º 11
0
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
Ejemplo n.º 12
0
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
Ejemplo n.º 13
0
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()
Ejemplo n.º 14
0
def test_default_global_group_policy():
    assert isinstance(gossip.get_global_group()
                      .get_exception_policy(), gossip.RaiseImmediately)