diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index 6875c39..ea81f34 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -22,7 +22,7 @@ def get_plugin(name: str, ui: UI, settings: MutableMapping) -> "Plugin": raise PluginNotRegistered(name) if len(plugins) > 1: raise PluginNameConflict(plugins) - plugin = plugins[0].load() # type: ignore[index] # index requires a int but class expects a string + plugin = plugins[name].load() return plugin(ui, settings) diff --git a/src/ofxstatement/tests/test_plugin.py b/src/ofxstatement/tests/test_plugin.py index 34618d1..2f82d63 100644 --- a/src/ofxstatement/tests/test_plugin.py +++ b/src/ofxstatement/tests/test_plugin.py @@ -2,6 +2,13 @@ import mock +import sys + +if sys.version_info < (3, 10): + from importlib_metadata import EntryPoints +else: + from importlib.metadata import EntryPoints + from ofxstatement import plugin @@ -13,7 +20,9 @@ def get_parser(self): ep = mock.Mock() ep.load.return_value = SamplePlugin - ep_patch = mock.patch("ofxstatement.plugin.entry_points", return_value=[ep]) + ep_patch = mock.patch( + "ofxstatement.plugin.entry_points", return_value=EntryPoints([ep]) + ) with ep_patch: p = plugin.get_plugin("sample", mock.Mock("UI"), mock.Mock("Settings")) self.assertIsInstance(p, SamplePlugin)