File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ from io import BytesIO
34from pathlib import Path
45
56import pytest
67
7- from PIL import Image , ImagePalette
8+ from PIL import Image , ImagePalette , PaletteFile
89
910from .helper import assert_image_equal , assert_image_equal_tofile
1011
@@ -202,6 +203,19 @@ def test_2bit_palette(tmp_path: Path) -> None:
202203 assert_image_equal_tofile (img , outfile )
203204
204205
206+ def test_getpalette () -> None :
207+ b = BytesIO (b"0 1\n 1 2 3 4" )
208+ p = PaletteFile .PaletteFile (b )
209+
210+ palette , rawmode = p .getpalette ()
211+ assert palette [:6 ] == b"\x01 \x01 \x01 \x02 \x03 \x04 "
212+ assert rawmode == "RGB"
213+
214+
205215def test_invalid_palette () -> None :
206216 with pytest .raises (OSError ):
207217 ImagePalette .load ("Tests/images/hopper.jpg" )
218+
219+ b = BytesIO (b"1" * 101 )
220+ with pytest .raises (SyntaxError , match = "bad palette file" ):
221+ PaletteFile .PaletteFile (b )
You can’t perform that action at this time.
0 commit comments