"""Shared pytest fixtures for the kernbench test suite. Session-scoped topology caching: ``resolve_topology("topology.yaml")`` is pure (no side effects), so we cache the result across all tests in a worker process. Each test still builds its own ``GraphEngine`` (which is stateful/SimPy-event-consuming and MUST NOT be shared). """ from __future__ import annotations import pytest from kernbench.topology.builder import resolve_topology @pytest.fixture(scope="session") def topology(): """Session-scoped parsed topology (immutable graph + spec). Usage in tests:: def test_foo(topology): engine = GraphEngine(topology.topology_obj, enable_data=True) """ return resolve_topology("topology.yaml") @pytest.fixture(scope="session") def topology_obj(topology): """The TopologyGraph inside the handle (convenience shortcut).""" return topology.topology_obj @pytest.fixture(scope="session") def spec(topology): """Topology spec dict (convenience shortcut).""" return topology.topology_obj.spec