From b839bf6b05dfe500db8ddcd82f1dd37fb77a0c72 Mon Sep 17 00:00:00 2001 From: Sebastian Mohr Date: Fri, 19 Dec 2025 23:18:26 +0100 Subject: [PATCH] Set the class module during plugin registration to not trigger the plugin load dedup. --- beets/test/helper.py | 4 +--- test/test_plugins.py | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/beets/test/helper.py b/beets/test/helper.py index 1488a24fa..e70f8b844 100644 --- a/beets/test/helper.py +++ b/beets/test/helper.py @@ -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 diff --git a/test/test_plugins.py b/test/test_plugins.py index b169a3d9b..34d679d82 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -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):