diff --git a/glue/main.py b/glue/main.py index 0637c6d5e..0b228b1ce 100644 --- a/glue/main.py +++ b/glue/main.py @@ -59,8 +59,7 @@ def load_plugins(splash=None, require_qt_plugins=False, plugins_to_load=None): n_plugins = len(plugins_to_require) for i_plugin, item in enumerate(list(iter_plugin_entry_points())): - - if item.module in plugins_to_load: + if item.module in plugins_to_require: if item.module not in _installed_plugins: _installed_plugins.add(item.name) @@ -115,3 +114,9 @@ def load_plugins(splash=None, require_qt_plugins=False, plugins_to_load=None): # that were previously read. from glue._settings_helpers import load_settings load_settings() + +def list_plugins(): + """ + Function to list all plugins that are currently loaded + """ + return sorted(_loaded_plugins) \ No newline at end of file diff --git a/glue/tests/test_main.py b/glue/tests/test_main.py index 10b35bd86..961416a8d 100644 --- a/glue/tests/test_main.py +++ b/glue/tests/test_main.py @@ -1,6 +1,21 @@ from unittest.mock import patch from glue.main import load_plugins +from glue.main import list_plugins + + +def test_load_plugins(capsys): + """ + Test customisable list of plugins load + """ + from glue.logger import logger + + with patch.object(logger, 'info') as info: + load_plugins() + + plugin = [call[0][0] for call in info.call_args_list] + assert False + def test_no_duplicate_loading(capsys): @@ -18,3 +33,13 @@ def test_no_duplicate_loading(capsys): for acall in info.call_args_list: if 'Loading plugin' in acall[0][0]: assert 'failed' in acall[0][0] + + +def test_list_plugins(): + """ + Regression test for retrieving the list of currently loaded plugins + """ + load_plugins(require_qt_plugins=False) + plugins = list_plugins() + assert isinstance(plugins, list) + assert len(plugins) == 14