From 450e6fd0e160027b09484985664aab880c65c6ad Mon Sep 17 00:00:00 2001 From: CyclingNinja Date: Tue, 4 Jun 2024 15:38:51 +0100 Subject: [PATCH] Complete tests and revert qt_refactor --- glue/main.py | 6 +++--- glue/tests/test_main.py | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/glue/main.py b/glue/main.py index 353cd7342..a428be40c 100644 --- a/glue/main.py +++ b/glue/main.py @@ -3,7 +3,7 @@ from importlib import import_module from glue.logger import logger -from glue._plugin_helpers import REQUIRED_PLUGINS +from glue._plugin_helpers import REQUIRED_PLUGINS, REQUIRED_PLUGINS_QT _loaded_plugins = set() @@ -50,8 +50,8 @@ def load_plugins(splash=None, require_qt_plugins=False, plugins_to_load=None): if plugins_to_load is None: plugins_to_load = [i.module for i in list(iter_plugin_entry_points())] - if plugins_to_load: - plugins_to_require = [*REQUIRED_PLUGINS] + if require_qt_plugins: + plugins_to_require = [*REQUIRED_PLUGINS, *REQUIRED_PLUGINS_QT] else: plugins_to_require = REQUIRED_PLUGINS else: diff --git a/glue/tests/test_main.py b/glue/tests/test_main.py index da995d8af..dd1a0013d 100644 --- a/glue/tests/test_main.py +++ b/glue/tests/test_main.py @@ -1,6 +1,7 @@ from unittest.mock import patch from glue.main import load_plugins, list_loaded_plugins, list_available_plugins +from glue._plugin_helpers import REQUIRED_PLUGINS def test_load_plugins(capsys): @@ -34,27 +35,38 @@ def test_no_duplicate_loading(capsys): with patch.object(logger, 'info') as info: load_plugins() + plugins = [] for acall in info.call_args_list: + plugins.append(acall[0][0]) if 'Loading plugin' in acall[0][0]: assert 'failed' in acall[0][0] + loaded_plugins = list_loaded_plugins() + assert 'glue.plugins.wcs_autolinking' in loaded_plugins + assert 'glue.core.data_exporters' in loaded_plugins + assert 'glue.plugins.coordinate_helpers' in loaded_plugins + assert len(loaded_plugins) == 5 + def test_list_loaded_plugins(): """ - Regression test for retrieving the list of currently loaded plugins + Unit test for retrieving the list of currently loaded plugins """ load_plugins(require_qt_plugins=False) plugins = list_loaded_plugins() assert isinstance(plugins, list) assert len(plugins) == 5 + for test_plugin in REQUIRED_PLUGINS: + assert test_plugin in plugins def test_list_available_plugins(): """ - Regression test for retrieving the list of currently available plugins + Unit test for retrieving the list of currently available plugins """ available_plugins = list_available_plugins() assert isinstance(available_plugins, list) assert len(available_plugins) == 7 - assert 'casa_formats_io.glue_factory' in available_plugins assert 'glue.plugins.wcs_autolinking' in available_plugins + assert 'glue.core.data_exporters' in available_plugins + assert 'glue.plugins.coordinate_helpers' in available_plugins