[AI]
Поддержка плагинов
This commit is contained in:
26
tests/test_plugins.py
Normal file
26
tests/test_plugins.py
Normal 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)
|
||||
Reference in New Issue
Block a user