mirror of
https://github.com/ChristianLight/tutor.git
synced 2025-01-12 01:45:39 +00:00
chore: refactor clear_cache code
This commit is contained in:
parent
e9b38fc668
commit
53524d9077
@ -8,7 +8,7 @@ from tutor.types import Config, get_typed
|
||||
|
||||
class PluginsTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
plugins.Plugins.clear()
|
||||
plugins.Plugins.clear_cache()
|
||||
|
||||
@patch.object(plugins.DictPlugin, "iter_installed", return_value=[])
|
||||
def test_iter_installed(self, dict_plugin_iter_installed: Mock) -> None:
|
||||
|
@ -182,6 +182,11 @@ class BasePlugin:
|
||||
def iter_load(cls) -> Iterator["BasePlugin"]:
|
||||
raise NotImplementedError
|
||||
|
||||
@classmethod
|
||||
def clear_cache(cls) -> None:
|
||||
cls._IS_LOADED = False
|
||||
cls.INSTALLED.clear()
|
||||
|
||||
|
||||
class EntrypointPlugin(BasePlugin):
|
||||
"""
|
||||
@ -324,9 +329,9 @@ class Plugins:
|
||||
self.hooks[hook_name][plugin.name] = services
|
||||
|
||||
@classmethod
|
||||
def clear(cls) -> None:
|
||||
def clear_cache(cls) -> None:
|
||||
for PluginClass in cls.PLUGIN_CLASSES:
|
||||
PluginClass.INSTALLED.clear()
|
||||
PluginClass.clear_cache()
|
||||
|
||||
@classmethod
|
||||
def iter_installed(cls) -> Iterator[BasePlugin]:
|
||||
|
Loading…
Reference in New Issue
Block a user