Assert getpalette does not return None

This commit is contained in:
Andrew Murray 2025-10-11 14:48:13 +11:00
parent 755ebb8307
commit a66d0d1f05
2 changed files with 8 additions and 2 deletions

View File

@ -62,6 +62,7 @@ def test_putpalette_with_alpha_values() -> None:
expected = im.convert("RGBA")
palette = im.getpalette()
assert palette is not None
transparency = im.info.pop("transparency")
palette_with_alpha_values = []

View File

@ -76,9 +76,14 @@ def test_consecutive() -> None:
def test_palette_mmap() -> None:
# Using mmap in ImageFile can require to reload the palette.
with Image.open("Tests/images/multipage-mmap.tiff") as im:
color1 = im.getpalette()[:3]
palette = im.getpalette()
assert palette is not None
color1 = palette[:3]
im.seek(0)
color2 = im.getpalette()[:3]
palette = im.getpalette()
assert palette is not None
color2 = palette[:3]
assert color1 == color2