"""Shared pytest fixtures and import stubs. Hy-MT2's runtime imports torch and transformers, neither of which we want as a test dependency for CI. We stub them out so the prompt-builder and parser logic — the only deterministic parts — stay testable on a 0-cost CI runner. """ import sys import os.path as osp import unittest.mock as mock # Make the package importable regardless of where pytest is invoked from. REPO_ROOT = osp.abspath(osp.join(osp.dirname(__file__), "..")) if REPO_ROOT not in sys.path: sys.path.insert(0, REPO_ROOT) # Stub torch BEFORE nodes.runtime is imported anywhere. if "torch" not in sys.modules: fake_torch = mock.MagicMock(name="torch") fake_torch.bfloat16 = "bf16_sentinel" fake_torch.float16 = "fp16_sentinel" fake_torch.float32 = "fp32_sentinel" fake_torch.cuda.is_available.return_value = False sys.modules["torch"] = fake_torch