From 57392946ba2422d0080657c09da4da392fbeb640 Mon Sep 17 00:00:00 2001 From: geisserml Date: Sun, 18 Jun 2023 22:19:17 +0200 Subject: [PATCH] PIL buffer test: relax copy assert to warning Our test suite should not fail if PIL improves in this regard, esp. seeing as test suite failure inhibites new releases. --- tests_old/test_renderer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests_old/test_renderer.py b/tests_old/test_renderer.py index 5ca63e74f..f94902b4d 100644 --- a/tests_old/test_renderer.py +++ b/tests_old/test_renderer.py @@ -3,6 +3,7 @@ import math import numpy +import warnings import PIL.Image import pytest import pypdfium2 as pdfium @@ -385,6 +386,7 @@ def test_pil_nocopy_where_possible(bitmap_format, rev_byteorder, is_referenced, assert pil_image.getpixel((0, 0)) == pixel_a bitmap.buffer[0] = val_b + if is_referenced: # changes to the buffer are reflected in the image @@ -396,4 +398,7 @@ def test_pil_nocopy_where_possible(bitmap_format, rev_byteorder, is_referenced, assert bitmap.buffer[0] == val_a else: - assert pil_image.getpixel((0, 0)) == pixel_a + if pil_image.getpixel((0, 0)) == pixel_b: + warnings.warn(f"PIL now references {bitmap.mode} mode bitmaps.") + else: + assert pil_image.getpixel((0, 0)) == pixel_a