diff --git a/xblock/plugin.py b/xblock/plugin.py index ad7b8d502..6b499946c 100644 --- a/xblock/plugin.py +++ b/xblock/plugin.py @@ -28,6 +28,10 @@ def __init__(self, all_entry_points): super().__init__(msg) +class AmbiguousPluginOverrideError(AmbiguousPluginError): + """Raised when a class name produces more than one override for an entry_point.""" + + def _default_select_no_override(identifier, all_entry_points): # pylint: disable=inconsistent-return-statements """ Selects plugin for the given identifier, raising on error: @@ -72,7 +76,7 @@ def default_select(identifier, all_entry_points): if len(overrides) == 1: return overrides[0] elif len(overrides) > 1: - raise AmbiguousPluginError(all_entry_points) + raise AmbiguousPluginOverrideError(overrides) return default_plugin diff --git a/xblock/test/test_plugin.py b/xblock/test/test_plugin.py index 681d5c634..08049fa04 100644 --- a/xblock/test/test_plugin.py +++ b/xblock/test/test_plugin.py @@ -6,7 +6,7 @@ from xblock.core import XBlock from xblock import plugin -from xblock.plugin import AmbiguousPluginError, PluginMissingError +from xblock.plugin import AmbiguousPluginError, AmbiguousPluginOverrideError, PluginMissingError class AmbiguousBlock1(XBlock): @@ -82,7 +82,7 @@ def test_plugin_override_ambiguous(): "xblock.test.test_plugin.AmbiguousBlock1, " "xblock.test.test_plugin.AmbiguousBlock2" ) - with pytest.raises(AmbiguousPluginError, match=expected_msg): + with pytest.raises(AmbiguousPluginOverrideError, match=expected_msg): XBlock.load_class("overridden_block")