diff --git a/core/src/toga/images.py b/core/src/toga/images.py index 2b808fcfc..18f3374f9 100644 --- a/core/src/toga/images.py +++ b/core/src/toga/images.py @@ -120,6 +120,7 @@ class Image: converters = [] for image_plugin in entry_points(group="toga.image_formats"): + print(image_plugin) converter = importlib.import_module(f"{image_plugin.value}") if converter.image_class is not None: converters.append(converter) diff --git a/core/tests/test_images.py b/core/tests/test_images.py index 4c3f1e326..0fb5fa2c7 100644 --- a/core/tests/test_images.py +++ b/core/tests/test_images.py @@ -4,6 +4,7 @@ import PIL.Image import pytest import toga +from toga_dummy.plugins import disabled_converter from toga_dummy.plugins.image_converter import CustomImage, CustomImageSubclass from toga_dummy.utils import assert_action_performed_with @@ -286,6 +287,11 @@ def test_as_format_custom_class(app, ImageClass): assert custom_image.size == (144, 72) +def test_disabled_image_plugin(app): + """Disabled image plugin shouldn't be available.""" + assert disabled_converter not in toga.Image._converters() + + # None is same as supplying nothing; also test a random unrecognized class @pytest.mark.parametrize("arg", [None, toga.Button]) def test_as_format_invalid_input(app, arg): diff --git a/dummy/pyproject.toml b/dummy/pyproject.toml index 887b32a42..988be13de 100644 --- a/dummy/pyproject.toml +++ b/dummy/pyproject.toml @@ -63,3 +63,4 @@ dependencies = [ [project.entry-points."toga.image_formats"] dummy = "toga_dummy.plugins.image_converter" +disabled = "toga_dummy.plugins.disabled_converter" diff --git a/dummy/src/toga_dummy/plugins/disabled_converter.py b/dummy/src/toga_dummy/plugins/disabled_converter.py new file mode 100644 index 000000000..119d69628 --- /dev/null +++ b/dummy/src/toga_dummy/plugins/disabled_converter.py @@ -0,0 +1,4 @@ +# With image_class set to None, this shouldn't be added to the list of available +# converters. This simulates what the PIL plugin does if PIL isn't installed. + +image_class = None