Test an empty string comment in arguments removes existing comment

This commit is contained in:
Andrew Murray 2022-05-21 23:29:55 +10:00
parent db76eaa12c
commit 67f5e5d272

View File

@ -853,15 +853,17 @@ def test_write_comment(tmp_path):
) )
def test_write_no_comment(tmp_path): def test_empty_string_comment(tmp_path):
out = str(tmp_path / "temp.gif") out = str(tmp_path / "temp.gif")
with Image.open("Tests/images/dispose_prev.gif") as im: with Image.open("Tests/images/chi.gif") as im:
# Empty comment="" arg should suppress all comments assert "comment" in im.info
# Empty string comment should suppress existing comment
im.save(out, save_all=True, comment="") im.save(out, save_all=True, comment="")
with Image.open(out) as reread:
assert "comment" not in reread.info with Image.open(out) as reread:
for frame in ImageSequence.Iterator(reread): for frame in ImageSequence.Iterator(reread):
assert "comment" not in frame.info assert "comment" not in frame.info
def test_version(tmp_path): def test_version(tmp_path):