from pathlib import Path import cv2 import numpy as np import pytest REPO = Path(__file__).parent.parent @pytest.fixture def photo() -> np.ndarray: """A synthetic photo: dark wall, one bright 'screen' with digits on it.""" image = np.full((600, 800, 3), 40, dtype=np.uint8) cv2.rectangle(image, (300, 200), (500, 380), (220, 220, 220), thickness=-1) for row, text in enumerate(["30:06", "7283", "2:04"]): cv2.putText(image, text, (320, 250 + row * 50), cv2.FONT_HERSHEY_SIMPLEX, 1.2, (20, 20, 20), 3) return image @pytest.fixture def photo_path(tmp_path: Path, photo: np.ndarray) -> Path: path = tmp_path / "IMG_0001.jpg" cv2.imwrite(str(path), photo) return path @pytest.fixture def corrupt_path(tmp_path: Path) -> Path: path = tmp_path / "corrupt.jpg" path.write_text("this is not a JPEG") return path