mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Merge pull request #719 from wiredfool/imagepalette
Tests for Imagepalette.save()
This commit is contained in:
commit
7d232a3c32
|
@ -101,8 +101,11 @@ class ImagePalette:
|
|||
fp.write("# Mode: %s\n" % self.mode)
|
||||
for i in range(256):
|
||||
fp.write("%d" % i)
|
||||
for j in range(i, len(self.palette), 256):
|
||||
for j in range(i*len(self.mode), (i+1)*len(self.mode)):
|
||||
try:
|
||||
fp.write(" %d" % self.palette[j])
|
||||
except IndexError:
|
||||
fp.write(" 0")
|
||||
fp.write("\n")
|
||||
fp.close()
|
||||
|
||||
|
|
|
@ -26,15 +26,15 @@ class TestImagePalette(PillowTestCase):
|
|||
|
||||
def test_file(self):
|
||||
|
||||
palette = ImagePalette()
|
||||
palette = ImagePalette("RGB", list(range(256))*3)
|
||||
|
||||
file = self.tempfile("temp.lut")
|
||||
f = self.tempfile("temp.lut")
|
||||
|
||||
palette.save(file)
|
||||
palette.save(f)
|
||||
|
||||
from PIL.ImagePalette import load, raw
|
||||
|
||||
p = load(file)
|
||||
p = load(f)
|
||||
|
||||
# load returns raw palette information
|
||||
self.assertEqual(len(p[0]), 768)
|
||||
|
@ -42,7 +42,7 @@ class TestImagePalette(PillowTestCase):
|
|||
|
||||
p = raw(p[1], p[0])
|
||||
self.assertIsInstance(p, ImagePalette)
|
||||
|
||||
self.assertEqual(p.palette, palette.tobytes())
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user