mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 09:26:16 +03:00
More GIMP palette tests
This commit is contained in:
parent
6a85d5184c
commit
dba0e7960a
12
Tests/images/bad_palette_entry.gpl
Normal file
12
Tests/images/bad_palette_entry.gpl
Normal 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
|
12
Tests/images/bad_palette_file.gpl
Normal file
12
Tests/images/bad_palette_file.gpl
Normal 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
|
12
Tests/images/custom_gimp_palette.gpl
Normal file
12
Tests/images/custom_gimp_palette.gpl
Normal 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
|
|
@ -12,6 +12,23 @@ class TestImage(PillowTestCase):
|
||||||
with open('Tests/images/hopper.jpg', 'rb') as fp:
|
with open('Tests/images/hopper.jpg', 'rb') as fp:
|
||||||
self.assertRaises(SyntaxError, lambda: GimpPaletteFile(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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user