Поддержка плагинов
This commit is contained in:
Mikan
2025-12-08 17:27:26 +03:00
parent 8da965234c
commit 5b08f6792a
4 changed files with 52 additions and 3 deletions

26
tests/test_plugins.py Normal file
View File

@@ -0,0 +1,26 @@
from pathlib import Path
def test_load_plugins():
# Создаём плагин
plugin_dir = Path("tests/plugins")
plugin_dir.mkdir(exist_ok=True)
plugin_path = plugin_dir / "test_plugin.py"
plugin_path.write_text("""
from src.handlers import register_handler
@register_handler("admonition")
def handle_admonition(node, doc, images_dir, style_reg):
p = doc.add_paragraph("Тест плагина")
""", encoding="utf-8")
# Загружаем
from src.core.plugin_loader import load_plugins_from_path
load_plugins_from_path(plugin_dir)
# Проверяем, что обработчик зарегистрирован
from src.handlers import get_handler
handler = get_handler("admonition")
assert handler is not None
plugin_path.unlink(missing_ok=True)