def register_plugin_test(self): class TestPlugin(PluginManager): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.custom = [] def custom_function(self): return self.custom SignalManager.register_plugin(TestPlugin) self.assertTrue( TestPlugin in SignalManager.__bases__, 'TestPlugin should be a subclass of the PluginManager') sig = SignalManager() self.assertEqual([], sig.custom_function())
def duplicate_register_plugin_test(self): class TestPlugin(PluginManager): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.custom = [] def custom_function(self): return self.custom length_before = len(SignalManager.__bases__) SignalManager.register_plugin(TestPlugin) SignalManager.register_plugin(TestPlugin) length_after = len(SignalManager.__bases__) self.assertTrue(length_after - length_before == 1, 'Should not create duplicate plugins') sig = SignalManager() self.assertEqual([], sig.custom_function())