pupilometer/tests/conftest.py
2025-11-28 16:18:30 +07:00

22 lines
709 B
Python

import pytest
from pypylon import pylon
@pytest.fixture(scope="session")
def camera_available():
"""
Pytest fixture that checks for a connected Basler camera.
If no camera is found, it skips the tests that depend on this fixture.
"""
try:
tl_factory = pylon.TlFactory.GetInstance()
devices = tl_factory.EnumerateDevices()
if not devices:
pytest.skip("No Basler camera found. Skipping tests that require a camera.")
# You can also add a photo capture test here if you want
# For now, just detecting the camera is enough
except Exception as e:
pytest.fail(f"An error occurred during camera detection: {e}")