"""Shared test fixtures: synthetic media generated in-memory.""" from __future__ import annotations import io import numpy as np import pytest from PIL import Image @pytest.fixture def jpeg_bytes() -> bytes: """A small valid JPEG with no EXIF.""" img = Image.fromarray( (np.random.default_rng(0).random((64, 64, 3)) * 255).astype("uint8") ) buf = io.BytesIO() img.save(buf, format="JPEG", quality=85) return buf.getvalue() @pytest.fixture def png_bytes() -> bytes: """A small valid PNG.""" img = Image.new("RGB", (48, 48), (120, 30, 200)) buf = io.BytesIO() img.save(buf, format="PNG") return buf.getvalue() @pytest.fixture def jpeg_with_software(tmp_path): """Write a JPEG carrying a Photoshop Software EXIF tag; return its path.""" from PIL import Image as PImage img = PImage.new("RGB", (32, 32), (10, 20, 30)) exif = img.getexif() exif[0x0131] = "Adobe Photoshop 25.0" # Software tag path = tmp_path / "edited.jpg" img.save(path, format="JPEG", exif=exif) return str(path)