Pillow/test/test_image_load.py
2014-06-05 11:39:29 +03:00

36 lines
758 B
Python

from helper import unittest, PillowTestCase, lena
from PIL import Image
import os
class TestImageLoad(PillowTestCase):
def test_sanity(self):
im = lena()
pix = im.load()
self.assertEqual(pix[0, 0], (223, 162, 133))
def test_close(self):
im = Image.open("Images/lena.gif")
im.close()
self.assert_exception(ValueError, lambda: im.load())
self.assert_exception(ValueError, lambda: im.getpixel((0, 0)))
def test_contextmanager(self):
fn = None
with Image.open("Images/lena.gif") as im:
fn = im.fp.fileno()
os.fstat(fn)
self.assert_exception(OSError, lambda: os.fstat(fn))
if __name__ == '__main__':
unittest.main()
# End of file