From 0a76fbee1d98de9c080de8b6218d8cb1888a33de Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 10 Apr 2024 12:42:36 +0100 Subject: [PATCH] Add tests for set_image. --- tests/test_set_image.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/test_set_image.py diff --git a/tests/test_set_image.py b/tests/test_set_image.py new file mode 100644 index 0000000..61bbf65 --- /dev/null +++ b/tests/test_set_image.py @@ -0,0 +1,28 @@ +"""Set image tests for Inky.""" +import pytest + + +@pytest.mark.parametrize('resolution', [(800, 480), (600, 448), (400, 300), (212, 104), (250, 122)]) +def test_inky_set_image(GPIO, spidev, smbus2, resolution): + from PIL import Image + + from inky.inky import Inky + + phat = Inky(resolution) + + width, height = phat.resolution + + image = Image.new("P", (width, height)) + + for x in range(width): + image.putpixel((x, 0), x % 3) + + assert image.size == (width, height) + + phat.set_image(image) + phat.set_pixel(0, 0, 2) + + data = [x % 3 for x in range(width)] + data[0] = 2 + + assert phat.buf.flatten().tolist()[0:width] == data