Coverage for node / src / stigmem_node / plugins / testing.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-25 01:49 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-25 01:49 +0000
1"""Testing helpers for controlled plugin registry state."""
3from __future__ import annotations
5from collections.abc import Iterator
6from contextlib import contextmanager
8from .manifest import PluginManifest
9from .registry import HookRegistry, set_registry
12class TestPluginRegistry(HookRegistry):
13 """Named test subclass for fixtures and downstream plugin tests."""
16@contextmanager
17def stigmem_plugins(manifests: list[PluginManifest]) -> Iterator[TestPluginRegistry]:
18 """Temporarily replace the process registry with test plugin manifests."""
19 registry = TestPluginRegistry()
20 for manifest in manifests:
21 registry.register_plugin(manifest)
22 previous = set_registry(registry)
23 try:
24 yield registry
25 finally:
26 set_registry(previous)