Merge pull request #1326 from hugovk/more_gimp_palette_tests

More GIMP palette tests
This commit is contained in:
Alex Clark 2015-07-01 14:30:10 -04:00
commit 9dde5d3283
4 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,12 @@
GIMP Palette
Name: badpaletteentry
Columns: 4
#
0 0 0 Index 3
65 38
103 62 49 Index 6
79 73 72 Index 7
114 101 97 Index 8
208 127 100 Index 9
151 144 142 Index 10
221 207 199 Index 11

View File

@ -0,0 +1,12 @@
GIMP Palette
Name: badpalettefile
Columns: 4
#
0 0 0 Index 3
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
103 62 49 Index 6
79 73 72 Index 7
114 101 97 Index 8
208 127 100 Index 9
151 144 142 Index 10
221 207 199 Index 11

View File

@ -0,0 +1,12 @@
GIMP Palette
Name: custompalette
Columns: 4
#
0 0 0 Index 3
65 38 30 Index 4
103 62 49 Index 6
79 73 72 Index 7
114 101 97 Index 8
208 127 100 Index 9
151 144 142 Index 10
221 207 199 Index 11

View File

@ -12,6 +12,23 @@ class TestImage(PillowTestCase):
with open('Tests/images/hopper.jpg', 'rb') as fp:
self.assertRaises(SyntaxError, lambda: GimpPaletteFile(fp))
with open('Tests/images/bad_palette_file.gpl', 'rb') as fp:
self.assertRaises(SyntaxError, lambda: GimpPaletteFile(fp))
with open('Tests/images/bad_palette_entry.gpl', 'rb') as fp:
self.assertRaises(ValueError, lambda: GimpPaletteFile(fp))
def test_get_palette(self):
# Arrange
with open('Tests/images/custom_gimp_palette.gpl', 'rb') as fp:
palette_file = GimpPaletteFile(fp)
# Act
palette, mode = palette_file.getpalette()
# Assert
self.assertEqual(mode, "RGB")
if __name__ == '__main__':
unittest.main()