diff --git a/envisage/composite_plugin_manager.py b/envisage/composite_plugin_manager.py index 59e68510..8bd740d2 100644 --- a/envisage/composite_plugin_manager.py +++ b/envisage/composite_plugin_manager.py @@ -129,7 +129,8 @@ def remove_plugin(self, plugin): def start(self): """ Start the plugin manager. """ - map(lambda plugin: self.start_plugin(plugin), self) + for plugin in self: + self.start_plugin(plugin) return @@ -154,7 +155,8 @@ def stop(self): stop_order = list(iter(self)) stop_order.reverse() - map(lambda plugin: self.stop_plugin(plugin), stop_order) + for plugin in stop_order: + self.stop_plugin(plugin) return diff --git a/envisage/tests/composite_plugin_manager_test_case.py b/envisage/tests/composite_plugin_manager_test_case.py index ea6ee4e6..489ed258 100644 --- a/envisage/tests/composite_plugin_manager_test_case.py +++ b/envisage/tests/composite_plugin_manager_test_case.py @@ -36,6 +36,19 @@ def stop(self): return +class CustomException(Exception): + """ Custom exception used for testing purposes. """ + + pass + + +class RaisingPluginManager(PluginManager): + """ A PluginManager that raises on iteration. """ + + def __iter__(self): + raise CustomException("Something went wrong.") + + class CompositePluginManagerTestCase(unittest.TestCase): """ Tests for the composite plugin manager. """ @@ -160,6 +173,13 @@ def removed(obj, trait_name, old, new): return + def test_correct_exception_propagated_from_plugin_manager(self): + plugin_manager = CompositePluginManager( + plugin_managers=[RaisingPluginManager()] + ) + + self.assertRaises(CustomException, plugin_manager.start) + #### Private protocol ##################################################### def _plugin_count(self, plugin_manager):