Pillow/Tests/test_image_point.py

42 lines
1.2 KiB
Python
Raw Normal View History

2014-06-10 13:10:47 +04:00
from helper import unittest, PillowTestCase, tearDownModule, lena
2014-06-10 13:10:47 +04:00
import sys
2014-03-26 20:12:51 +04:00
2014-06-10 13:10:47 +04:00
class TestImagePoint(PillowTestCase):
2014-06-10 13:10:47 +04:00
def setUp(self):
if hasattr(sys, 'pypy_version_info'):
# This takes _forever_ on PyPy. Open Bug,
# see https://github.com/python-pillow/Pillow/issues/484
self.skipTest("Too slow on PyPy")
2014-06-10 13:10:47 +04:00
def test_sanity(self):
im = lena()
2014-06-10 13:10:47 +04:00
self.assertRaises(ValueError, lambda: im.point(list(range(256))))
im.point(list(range(256))*3)
im.point(lambda x: x)
2013-12-11 04:05:05 +04:00
2014-06-10 13:10:47 +04:00
im = im.convert("I")
self.assertRaises(ValueError, lambda: im.point(list(range(256))))
im.point(lambda x: x*1)
im.point(lambda x: x+1)
im.point(lambda x: x*1+1)
self.assertRaises(TypeError, lambda: im.point(lambda x: x-1))
self.assertRaises(TypeError, lambda: im.point(lambda x: x/1))
2013-12-11 04:05:05 +04:00
2014-06-10 13:10:47 +04:00
def test_16bit_lut(self):
""" Tests for 16 bit -> 8 bit lut for converting I->L images
see https://github.com/python-pillow/Pillow/issues/440
"""
2013-12-11 04:05:05 +04:00
2014-06-10 13:10:47 +04:00
im = lena("I")
im.point(list(range(256))*256, 'L')
if __name__ == '__main__':
unittest.main()
# End of file