mirror of
https://github.com/beetbox/beets.git
synced 2026-02-21 23:03:26 +01:00
Using plugin mixin to unload plugins.
This commit is contained in:
parent
8aa298d646
commit
3a2b6d85a4
1 changed files with 11 additions and 8 deletions
|
|
@ -36,7 +36,12 @@ from beets.importer import (
|
|||
)
|
||||
from beets.library import Item
|
||||
from beets.test import helper
|
||||
from beets.test.helper import AutotagStub, ImportHelper, TerminalImportMixin
|
||||
from beets.test.helper import (
|
||||
AutotagStub,
|
||||
ImportHelper,
|
||||
PluginMixin,
|
||||
TerminalImportMixin,
|
||||
)
|
||||
from beets.test.helper import PluginTestCase as BasePluginTestCase
|
||||
from beets.util import displayable_path, syspath
|
||||
|
||||
|
|
@ -550,17 +555,14 @@ def get_available_plugins():
|
|||
return [name for name in plugin_names if name != "_typing"]
|
||||
|
||||
|
||||
class TestImportAllPlugins:
|
||||
class TestImportAllPlugins(PluginMixin):
|
||||
@pytest.mark.parametrize("plugin_name", get_available_plugins())
|
||||
def test_import_plugin(self, caplog, plugin_name): #
|
||||
"""Test that a plugin is importable without an error using the
|
||||
load_plugins function."""
|
||||
|
||||
# Try to load all plugins
|
||||
from beets.plugins import load_plugins
|
||||
|
||||
caplog.set_level(logging.WARNING)
|
||||
load_plugins([plugin_name])
|
||||
self.load_plugins(plugin_name)
|
||||
|
||||
# Check for warnings, is a bit hacky but we can make full use of the beets
|
||||
# load_plugins code that way
|
||||
|
|
@ -575,13 +577,14 @@ class TestImportAllPlugins:
|
|||
continue
|
||||
records.append(record)
|
||||
|
||||
self.unload_plugins()
|
||||
self.unimport_plugins()
|
||||
|
||||
assert len(records) == 0, (
|
||||
f"Plugin '{plugin_name}' has issues during import. ",
|
||||
records,
|
||||
)
|
||||
|
||||
self.unimport_plugins()
|
||||
|
||||
def _is_spec_available(self, spec_name):
|
||||
"""Check if a module is available by its name."""
|
||||
return importlib.util.find_spec(spec_name) is not None
|
||||
|
|
|
|||
Loading…
Reference in a new issue