Set the class module during plugin registration to not trigger the plugin

load dedup.
This commit is contained in:
Sebastian Mohr 2025-12-19 23:18:26 +01:00
parent b325c5a2d8
commit b839bf6b05
2 changed files with 4 additions and 6 deletions

View file

@ -571,12 +571,10 @@ class PluginMixin(TestHelper):
beetsplug_pkg.__path__ = []
sys.modules[PLUGIN_NAMESPACE] = beetsplug_pkg
# Create the plugin module
if full_namespace in sys.modules:
raise ValueError(f"Plugin {name} already registered")
module = types.ModuleType(full_namespace)
module.__file__ = f"<{full_namespace}>"
module.__package__ = PLUGIN_NAMESPACE
plugin_class.__module__ = full_namespace
setattr(module, plugin_class.__name__, plugin_class)
# Register in sys.modules and as attribute of parent package

View file

@ -83,9 +83,9 @@ class TestPluginRegistration(PluginTest):
delimiter = types.MULTI_VALUE_DSV.delimiter
assert out == f"one{delimiter}two{delimiter}three\n"
def test_duplicate_field_typ(self):
"""Test that if another plugin tries to register the same type,
a PluginConflictError is raised.
def test_duplicate_field_type(self):
"""A PluginConflictError should be raised if
another plugin tries to register the same field_type str.
"""
class DuplicateDummyPlugin(plugins.BeetsPlugin):