Skip to content

Commit

Permalink
Add tests for set_image.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Apr 10, 2024
1 parent ffcc67a commit 2c215f8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_inky.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Set image tests for Inky."""
import pytest
import sys


@pytest.mark.parametrize('resolution', [(800, 480), (600, 448), (400, 300), (212, 104), (250, 122)])
def test_inky_set_image(GPIO, spidev, smbus2, resolution):
from inky.inky import Inky
from PIL import Image
import numpy

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

0 comments on commit 2c215f8

Please sign in to comment.