mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
4de5477b61
With the introduction and use of pytest, it is simple and easy to execute specific tests in isolation through documented command line arguments. Either by specifying the module path or through the `-k EXPRESSION` argument. There is no longer any need to provide the boilerplate: if __name__ == '__main__': unittest.main() To every test file. It is simply noise. The pattern remains in test files that aren't named with `test_*` as those files are not discovered and executed by pytest by default.
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
from .helper import PillowTestCase, hopper
|
|
|
|
|
|
class TestImagePoint(PillowTestCase):
|
|
|
|
def test_sanity(self):
|
|
im = hopper()
|
|
|
|
self.assertRaises(ValueError, im.point, list(range(256)))
|
|
im.point(list(range(256))*3)
|
|
im.point(lambda x: x)
|
|
|
|
im = im.convert("I")
|
|
self.assertRaises(ValueError, 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, im.point, lambda x: x-1)
|
|
self.assertRaises(TypeError, im.point, lambda x: x/1)
|
|
|
|
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
|
|
"""
|
|
im = hopper("I")
|
|
im.point(list(range(256))*256, 'L')
|
|
|
|
def test_f_lut(self):
|
|
""" Tests for floating point lut of 8bit gray image """
|
|
im = hopper('L')
|
|
lut = [0.5 * float(x) for x in range(256)]
|
|
|
|
out = im.point(lut, 'F')
|
|
|
|
int_lut = [x//2 for x in range(256)]
|
|
self.assert_image_equal(out.convert('L'), im.point(int_lut, 'L'))
|
|
|
|
def test_f_mode(self):
|
|
im = hopper('F')
|
|
self.assertRaises(ValueError, im.point, None)
|