Files
scanengine-3/tests/conftest.py
T
Thomas K Ales [MSE] 880b05fe86 working state commit
2026-09-25 08:13:03 -05:00

42 lines
1.1 KiB
Python
Executable File

"""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