Skip to content

Commit

Permalink
Fix exception swallowing in CompositePluginManager.start.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdickinson committed Aug 8, 2014
1 parent 69607e9 commit e1f16c5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions envisage/composite_plugin_manager.py
Expand Up @@ -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

Expand All @@ -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

Expand Down
20 changes: 20 additions & 0 deletions envisage/tests/composite_plugin_manager_test_case.py
Expand Up @@ -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. """

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit e1f16c5

Please sign in to comment.