From 5d40e6aead98fd7154c889b027c79f3e15c06661 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 18 Feb 2025 20:29:35 +1100 Subject: [PATCH] Test RGBX raw mode --- Tests/test_file_sun.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests/test_file_sun.py b/Tests/test_file_sun.py index ebb0693793c..c2f162cf9b4 100644 --- a/Tests/test_file_sun.py +++ b/Tests/test_file_sun.py @@ -72,6 +72,22 @@ def test_unsupported_file_type() -> None: pass +@pytest.mark.skipif( + not os.path.exists(EXTRA_DIR), reason="Extra image files not installed" +) +def test_rgbx() -> None: + with open(os.path.join(EXTRA_DIR, "32bpp.ras"), "rb") as fp: + data = fp.read() + + # Set file type to 3 + data = data[:20] + _binary.o32be(3) + data[24:] + + with Image.open(io.BytesIO(data)) as im: + r, g, b = im.split() + im = Image.merge("RGB", (b, g, r)) + assert_image_equal_tofile(im, os.path.join(EXTRA_DIR, "32bpp.png")) + + @pytest.mark.skipif( not os.path.exists(EXTRA_DIR), reason="Extra image files not installed" )