mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-27 20:43:43 +03:00
added write verification test
This commit is contained in:
parent
02931c4956
commit
d678b97444
BIN
Tests/images/lena_webp_write.ppm
Normal file
BIN
Tests/images/lena_webp_write.ppm
Normal file
Binary file not shown.
|
@ -3,6 +3,7 @@ from tester import *
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
def test_read():
|
def test_read():
|
||||||
|
""" Can we write a webp without error. Does it have the bits we expect?"""
|
||||||
|
|
||||||
file = "Images/lena.webp"
|
file = "Images/lena.webp"
|
||||||
im = Image.open(file)
|
im = Image.open(file)
|
||||||
|
@ -21,18 +22,22 @@ def test_read():
|
||||||
|
|
||||||
|
|
||||||
def test_write():
|
def test_write():
|
||||||
|
""" Can we write a webp without error. Does it have the bits we expect?"""
|
||||||
|
|
||||||
file = tempfile("temp.webp")
|
file = tempfile("temp.webp")
|
||||||
|
|
||||||
lena("RGB").save(file)
|
lena("RGB").save(file)
|
||||||
|
|
||||||
reloaded= Image.open(file)
|
im= Image.open(file)
|
||||||
reloaded.load()
|
im.load()
|
||||||
|
|
||||||
assert_equal(reloaded.mode, "RGB")
|
|
||||||
assert_equal(reloaded.size, (128, 128))
|
|
||||||
assert_equal(reloaded.format, "WEBP")
|
|
||||||
assert_no_exception(lambda: reloaded.load())
|
|
||||||
assert_no_exception(lambda: reloaded.getdata())
|
|
||||||
|
|
||||||
|
assert_equal(im.mode, "RGB")
|
||||||
|
assert_equal(im.size, (128, 128))
|
||||||
|
assert_equal(im.format, "WEBP")
|
||||||
|
assert_no_exception(lambda: im.load())
|
||||||
|
assert_no_exception(lambda: im.getdata())
|
||||||
|
|
||||||
|
# generated with: dwebp -ppm temp.webp -o lena_webp_write.ppm
|
||||||
|
target = Image.open('Tests/images/lena_webp_write.ppm')
|
||||||
|
assert_image_equal(im, target)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user