From 13081f4647d6c51e2c1dcb209e77e37821e2a835 Mon Sep 17 00:00:00 2001 From: chopratejas Date: Thu, 9 Apr 2026 16:24:15 -0700 Subject: [PATCH] Skip image tests when Pillow not installed (CI fix) Tests that create PIL images now have @needs_pillow decorator. Token estimation and tile math tests still run without Pillow. --- tests/test_image_compression.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_image_compression.py b/tests/test_image_compression.py index 7480d1471..d431c3ebc 100644 --- a/tests/test_image_compression.py +++ b/tests/test_image_compression.py @@ -20,6 +20,17 @@ from headroom.image.tile_optimizer import ( optimize_images_in_messages, ) +# Tests that create images need Pillow (optional dependency) +_HAS_PIL = False +try: + from PIL import Image as _Image # noqa: F401 + + _HAS_PIL = True +except ImportError: + pass + +needs_pillow = pytest.mark.skipif(not _HAS_PIL, reason="Pillow not installed") + # --------------------------------------------------------------------------- # Token estimation tests # --------------------------------------------------------------------------- @@ -153,6 +164,7 @@ def _make_anthropic_image_message(width: int, height: int) -> list[dict]: ] +@needs_pillow class TestMessageOptimization: def test_openai_message_optimized(self): """OpenAI message with large image gets tile-optimized.""" @@ -259,6 +271,7 @@ class TestOnnxRouter: # --------------------------------------------------------------------------- +@needs_pillow class TestFullPipeline: def test_compressor_with_openai_image(self): """Full compressor pipeline on OpenAI format.""" @@ -312,6 +325,7 @@ class TestFullPipeline: # --------------------------------------------------------------------------- +@needs_pillow class TestOcrRouting: @pytest.fixture(autouse=True) def _check_ocr(self):