2014-09-05 14:03:56 +04:00
|
|
|
from helper import unittest, PillowTestCase, hopper
|
2012-10-16 00:26:38 +04:00
|
|
|
|
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
class TestImageGetPalette(PillowTestCase):
|
|
|
|
|
|
|
|
def test_palette(self):
|
|
|
|
def palette(mode):
|
2014-09-05 14:03:56 +04:00
|
|
|
p = hopper(mode).getpalette()
|
2014-06-10 13:10:47 +04:00
|
|
|
if p:
|
|
|
|
return p[:10]
|
|
|
|
return None
|
2017-06-03 07:04:54 +03:00
|
|
|
self.assertIsNone(palette("1"))
|
|
|
|
self.assertIsNone(palette("L"))
|
|
|
|
self.assertIsNone(palette("I"))
|
|
|
|
self.assertIsNone(palette("F"))
|
2014-06-10 13:10:47 +04:00
|
|
|
self.assertEqual(palette("P"), [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
2017-06-03 07:04:54 +03:00
|
|
|
self.assertIsNone(palette("RGB"))
|
|
|
|
self.assertIsNone(palette("RGBA"))
|
|
|
|
self.assertIsNone(palette("CMYK"))
|
|
|
|
self.assertIsNone(palette("YCbCr"))
|
2014-06-10 13:10:47 +04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|