diff options
| author | 2024-04-23 00:38:24 -0400 | |
|---|---|---|
| committer | 2024-04-23 00:38:24 -0400 | |
| commit | 0199f695e93782d728bd31857afe54f4df92f351 (patch) | |
| tree | 34e9030a05a89461d222172615c74891fba1e5ef /tests/helper.py | |
| parent | 22b8f5dae59e876643e8e3002f72282f3e8608c5 (diff) | |
| parent | 9b0e86a8e74768c4fe848fb5ce8d754292db4e3e (diff) | |
Update upstream source from tag 'upstream/8.3.0'
Update to upstream version '8.3.0'
with Debian dir bc13791b86ab63e4473e92288f1749c55a6ad540
Diffstat (limited to 'tests/helper.py')
| -rw-r--r-- | tests/helper.py | 56 |
1 files changed, 15 insertions, 41 deletions
diff --git a/tests/helper.py b/tests/helper.py index 36558da..8fbebdb 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -6,23 +6,12 @@ a Site substitute for rendering tests. """ import os +import pathlib from contextlib import contextmanager -from yapsy.PluginManager import PluginManager - -import nikola.utils import nikola.shortcodes -from nikola.plugin_categories import ( - Command, - Task, - LateTask, - TemplateSystem, - PageCompiler, - TaskMultiplier, - CompilerExtension, - MarkdownExtension, - RestExtension, -) +import nikola.utils +from nikola.plugin_manager import PluginManager __all__ = ["cd", "FakeSite"] @@ -30,9 +19,11 @@ __all__ = ["cd", "FakeSite"] @contextmanager def cd(path): old_dir = os.getcwd() - os.chdir(path) - yield - os.chdir(old_dir) + try: + os.chdir(path) + yield + finally: + os.chdir(old_dir) class FakeSite: @@ -53,24 +44,11 @@ class FakeSite: "TRANSLATIONS": {"en": ""}, } self.EXTRA_PLUGINS = self.config["EXTRA_PLUGINS"] - self.plugin_manager = PluginManager( - categories_filter={ - "Command": Command, - "Task": Task, - "LateTask": LateTask, - "TemplateSystem": TemplateSystem, - "PageCompiler": PageCompiler, - "TaskMultiplier": TaskMultiplier, - "CompilerExtension": CompilerExtension, - "MarkdownExtension": MarkdownExtension, - "RestExtension": RestExtension, - } - ) + places = [pathlib.Path(nikola.utils.__file__).parent / "plugins"] + self.plugin_manager = PluginManager(plugin_places=places) self.shortcode_registry = {} - self.plugin_manager.setPluginInfoExtension("plugin") - places = [os.path.join(os.path.dirname(nikola.utils.__file__), "plugins")] - self.plugin_manager.setPluginPlaces(places) - self.plugin_manager.collectPlugins() + candidates = self.plugin_manager.locate_plugins() + self.plugin_manager.load_plugins(candidates) self.compiler_extensions = self._activate_plugins_of_category( "CompilerExtension" ) @@ -86,13 +64,9 @@ class FakeSite: """Activate all the plugins of a given category and return them.""" # this code duplicated in nikola/nikola.py plugins = [] - for plugin_info in self.plugin_manager.getPluginsOfCategory(category): - if plugin_info.name in self.config.get("DISABLED_PLUGINS"): - self.plugin_manager.removePluginFromCategory(plugin_info, category) - else: - self.plugin_manager.activatePluginByName(plugin_info.name) - plugin_info.plugin_object.set_site(self) - plugins.append(plugin_info) + for plugin_info in self.plugin_manager.get_plugins_of_category(category): + plugin_info.plugin_object.set_site(self) + plugins.append(plugin_info) return plugins def render_template(self, name, _, context): |
