conftest.py 929 B

123456789101112131415161718192021222324252627282930
  1. from pathlib import Path
  2. import pytest
  3. from unittest.mock import MagicMock
  4. @pytest.fixture
  5. def mock_ctx():
  6. ctx = MagicMock()
  7. ctx._hooks = {}
  8. ctx._skills = {}
  9. def register_hook(event, fn):
  10. ctx._hooks[event] = fn
  11. def register_skill(name, path):
  12. # Mimic hermes' real register_skill, which calls path.exists() and
  13. # therefore breaks on a str (the bug that silently disabled the whole
  14. # plugin, found 2026-07-23). Keeping that fidelity here means a
  15. # regression to str paths fails these tests instead of failing
  16. # silently inside hermes.
  17. if not isinstance(path, Path):
  18. raise AttributeError(
  19. f"register_skill requires a pathlib.Path, got {type(path).__name__}"
  20. )
  21. ctx._skills[name] = path
  22. ctx.register_hook.side_effect = register_hook
  23. ctx.register_skill.side_effect = register_skill
  24. return ctx