def test_onregister(self): plugins = PyPlugins() l = [] class MyApi: def pyevent_plugin_registered(self, plugin): l.append(plugin) def pyevent_plugin_unregistered(self, plugin): l.remove(plugin) myapi = MyApi() plugins.register(myapi) assert len(l) == 1 assert l[0] is myapi plugins.unregister(myapi) assert not l
def test_register(self): plugins = PyPlugins() class MyPlugin: pass my = MyPlugin() plugins.register(my) assert plugins.getplugins() == [my] my2 = MyPlugin() plugins.register(my2) assert plugins.getplugins() == [my, my2] assert plugins.isregistered(my) assert plugins.isregistered(my2) plugins.unregister(my) assert not plugins.isregistered(my) assert plugins.getplugins() == [my2]