Corrected test

This commit is contained in:
Andrew Murray 2022-10-10 11:46:33 +11:00
parent f9a3178bb3
commit 982d7c49e3

View File

@ -345,13 +345,14 @@ class TestCffi(AccessTest):
@pytest.mark.parametrize("mode", ("P", "PA")) @pytest.mark.parametrize("mode", ("P", "PA"))
def test_p_putpixel_rgb_rgba(self, mode): def test_p_putpixel_rgb_rgba(self, mode):
for color in [(255, 0, 0), (255, 0, 0, 127)]: for color in ((255, 0, 0), (255, 0, 0, 127 if mode == "PA" else 255)):
im = Image.new(mode, (1, 1)) im = Image.new(mode, (1, 1))
access = PyAccess.new(im, False) access = PyAccess.new(im, False)
access.putpixel((0, 0), color) access.putpixel((0, 0), color)
alpha = color[3] if len(color) == 4 and mode == "PA" else 255 if len(color) == 3:
assert im.convert("RGBA").getpixel((0, 0)) == (255, 0, 0, alpha) color += (255,)
assert im.convert("RGBA").getpixel((0, 0)) == color
class TestImagePutPixelError(AccessTest): class TestImagePutPixelError(AccessTest):