mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-29 18:23:24 +03:00
Converttest_image_load.py
This commit is contained in:
parent
b7eb1de922
commit
d385dd81a7
|
@ -1,27 +0,0 @@
|
||||||
from tester import *
|
|
||||||
|
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
def test_sanity():
|
|
||||||
|
|
||||||
im = lena()
|
|
||||||
|
|
||||||
pix = im.load()
|
|
||||||
|
|
||||||
assert_equal(pix[0, 0], (223, 162, 133))
|
|
||||||
|
|
||||||
def test_close():
|
|
||||||
im = Image.open("Images/lena.gif")
|
|
||||||
assert_no_exception(lambda: im.close())
|
|
||||||
assert_exception(ValueError, lambda: im.load())
|
|
||||||
assert_exception(ValueError, lambda: im.getpixel((0,0)))
|
|
||||||
|
|
||||||
def test_contextmanager():
|
|
||||||
fn = None
|
|
||||||
with Image.open("Images/lena.gif") as im:
|
|
||||||
fn = im.fp.fileno()
|
|
||||||
assert_no_exception(lambda: os.fstat(fn))
|
|
||||||
|
|
||||||
assert_exception(OSError, lambda: os.fstat(fn))
|
|
35
test/test_image_load.py
Normal file
35
test/test_image_load.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user