mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 09:56:17 +03:00
Use reading of comments to test saving comments
This commit is contained in:
parent
176b2a2000
commit
d3923f7142
|
@ -372,6 +372,20 @@ def test_comment():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_save_comment():
|
||||||
|
comment = "Created by Pillow"
|
||||||
|
out = BytesIO()
|
||||||
|
test_card.save(out, "JPEG2000", comment=comment)
|
||||||
|
out.seek(0)
|
||||||
|
|
||||||
|
with Image.open(out) as im:
|
||||||
|
assert im.info["comment"] == b"Created by Pillow"
|
||||||
|
|
||||||
|
too_long_comment = " " * 65532
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
test_card.save(out, "JPEG2000", comment=too_long_comment)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"test_file",
|
"test_file",
|
||||||
[
|
[
|
||||||
|
@ -391,20 +405,6 @@ def test_crashes(test_file):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_custom_comment():
|
|
||||||
output_stream = BytesIO()
|
|
||||||
unique_comment = "This is a unique comment, which should be found below"
|
|
||||||
test_card.save(output_stream, "JPEG2000", comment=unique_comment)
|
|
||||||
output_stream.seek(0)
|
|
||||||
data = output_stream.read()
|
|
||||||
# Lazy method to determine if the comment is in the image generated
|
|
||||||
assert bytes(unique_comment, "utf-8") in data
|
|
||||||
|
|
||||||
too_long_comment = " " * 65532
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
test_card.save(output_stream, "JPEG2000", comment=too_long_comment)
|
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature_version("jpg_2000", "2.4.0")
|
@skip_unless_feature_version("jpg_2000", "2.4.0")
|
||||||
def test_plt_marker():
|
def test_plt_marker():
|
||||||
# Search the start of the codesteam for the PLT box (id 0xFF58)
|
# Search the start of the codesteam for the PLT box (id 0xFF58)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user