Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Nov 29, 2021
1 parent af7e1a2 commit da07e0f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Binary file added Tests/images/dispose_bgnd_rgba.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions Tests/test_file_gif.py
Expand Up @@ -163,6 +163,32 @@ def test_roundtrip_save_all(tmp_path):
assert reread.n_frames == 5


@pytest.mark.parametrize(
"path, mode",
(
("Tests/images/dispose_bgnd.gif", "RGB"),
# Hexeditted copy of dispose_bgnd to add transparency
("Tests/images/dispose_bgnd_rgba.gif", "RGBA"),
),
)
def test_loading_multiple_palettes(path, mode):
with Image.open(path) as im:
assert im.mode == "P"
first_frame_colors = im.palette.colors.keys()
original_color = im.convert("RGB").load()[0, 0]

im.seek(1)
assert im.mode == mode
if mode == "RGBA":
im = im.convert("RGB")

# Check a color only from the old palette
assert im.load()[0, 0] == original_color

# Check a color from the new palette
assert im.load()[24, 24] not in first_frame_colors


def test_headers_saving_for_animated_gifs(tmp_path):
important_headers = ["background", "version", "duration", "loop"]
# Multiframe image
Expand Down

0 comments on commit da07e0f

Please sign in to comment.