More ImagePalette.py tests and remove unused and uncallable new()

This commit is contained in:
hugovk 2014-07-21 23:18:46 +03:00
parent 7155919b5b
commit d06735b49e
2 changed files with 36 additions and 5 deletions

View File

@ -18,7 +18,7 @@
import array
import warnings
from PIL import Image, ImageColor
from PIL import ImageColor
class ImagePalette:
@ -162,10 +162,6 @@ def make_gamma_lut(exp):
return lut
def new(mode, data):
return Image.core.new_palette(mode, data)
def negative(mode="RGB"):
palette = list(range(256))
palette.reverse()

View File

@ -111,6 +111,41 @@ class TestImagePalette(PillowTestCase):
DeprecationWarning,
lambda: _make_gamma_lut(exp))
def test_rawmode_valueerrors(self):
# Arrange
from PIL.ImagePalette import raw
palette = raw("RGB", list(range(256))*3)
# Act / Assert
self.assertRaises(ValueError, lambda: palette.tobytes())
self.assertRaises(ValueError, lambda: palette.getcolor((1, 2, 3)))
f = self.tempfile("temp.lut")
self.assertRaises(ValueError, lambda: palette.save(f))
def test_getdata(self):
# Arrange
data_in = list(range(256))*3
palette = ImagePalette("RGB", data_in)
# Act
mode, data_out = palette.getdata()
# Assert
self.assertEqual(mode, "RGB;L")
def test_rawmode_getdata(self):
# Arrange
from PIL.ImagePalette import raw
data_in = list(range(256))*3
palette = raw("RGB", data_in)
# Act
rawmode, data_out = palette.getdata()
# Assert
self.assertEqual(rawmode, "RGB")
self.assertEqual(data_in, data_out)
if __name__ == '__main__':
unittest.main()