Pillow/test/test_image_load.py

36 lines
746 B
Python
Raw Normal View History

2014-06-05 12:39:29 +04:00
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()
2014-06-05 12:45:01 +04:00
self.assertRaises(ValueError, lambda: im.load())
self.assertRaises(ValueError, lambda: im.getpixel((0, 0)))
2014-06-05 12:39:29 +04:00
def test_contextmanager(self):
fn = None
with Image.open("Images/lena.gif") as im:
fn = im.fp.fileno()
os.fstat(fn)
2014-06-05 12:45:01 +04:00
self.assertRaises(OSError, lambda: os.fstat(fn))
2014-06-05 12:39:29 +04:00
if __name__ == '__main__':
unittest.main()
# End of file