"""Shared test setup: repo-root imports, headless Qt, pyueye stub. The IDS uEye SDK (pyueye + libueye) only exists on the Linux rig. On any other machine we stub the module before hardware.uc480_camera is imported; everything in uc480_camera references `ueye.*` at call time, not import time, so an attribute-permissive dummy is sufficient for constructing windows and importing modules. """ import os import sys import types from pathlib import Path ROOT = Path(__file__).resolve().parent.parent if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") try: import pyueye # noqa: F401 except ImportError: class _UeyeStub: """Permissive attribute sink standing in for pyueye.ueye.""" IS_SUCCESS = 0 def __getattr__(self, name): return _UeyeStub() def __call__(self, *args, **kwargs): return _UeyeStub() def __or__(self, other): return 0 def __ror__(self, other): return 0 _pyueye = types.ModuleType("pyueye") _pyueye.ueye = _UeyeStub() sys.modules["pyueye"] = _pyueye