Recommended way of testing app using Pillow #8945
-
I browse official tests: to get general idea and I have questions: How are you testing your Pillow scripts apps? I am creating project with massive image generation for weather station and I want simply create tests (I prefer pytest) to be sure when I change one part it is not messes another. I am looking ideas how do it correctly as I don't have experience with scripts which drawing. My first thought is create display image as matrix which is 16-color grayscale and using 1/0 match drawed part and based on this create all tests suite using methid get_pixel, but it seems complicated and it is needed extra boilerplate. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi. As you have probably gathered, our Tests directory uses pytest. It is for testing that Pillow behaves as expected. You can read more about how to run our test suite at https://github.com/python-pillow/Pillow/blob/main/Tests/README.rst
You might be interested in a discussion where another user has shared their application - #8561
It sounds like you're describing from PIL import Image
im = Image.new("RGB", (100, 100))
expected = Image.new("RGB", (100, 100))
for x in range(im.width):
for y in range(im.height):
assert im.getpixel((x, y)) == expected.getpixel((x, y)) You may find using from PIL import Image
im = Image.new("RGB", (100, 100))
expected = Image.new("RGB", (100, 100))
assert im.tobytes() == expected.tobytes() An example of this in our test suite is at Lines 84 to 87 in 07df26a |
Beta Was this translation helpful? Give feedback.
Hi. As you have probably gathered, our Tests directory uses pytest. It is for testing that Pillow behaves as expected. You can read more about how to run our test suite at https://github.com/python-pillow/Pillow/blob/main/Tests/README.rst
You might be interested in a discussion where another user has shared their application - #8561
It sounds like you're describing