Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Aug 1, 2021
1 parent 8828080 commit 8045ecc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
Binary file added Tests/images/expected_to_read.jp2
Binary file not shown.
Binary file added Tests/images/invalid_header_length.jp2
Binary file not shown.
Binary file added Tests/images/not_enough_data.jp2
Binary file not shown.
16 changes: 15 additions & 1 deletion Tests/test_file_jpeg2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from PIL import Image, ImageFile, Jpeg2KImagePlugin, features
from PIL import Image, ImageFile, Jpeg2KImagePlugin, UnidentifiedImageError, features

from .helper import (
assert_image_equal,
Expand Down Expand Up @@ -159,6 +159,20 @@ def test_load_dpi():
assert "dpi" not in im.info


def test_header_errors():
for path in (
"Tests/images/invalid_header_length.jp2",
"Tests/images/not_enough_data.jp2",
):
with pytest.raises(UnidentifiedImageError):
with Image.open(path):
pass

with pytest.raises(OSError):
with Image.open("Tests/images/expected_to_read.jp2"):
pass


def test_layers_type(tmp_path):
outfile = str(tmp_path / "temp_layers.jp2")
for quality_layers in [[100, 50, 10], (100, 50, 10), None]:
Expand Down

0 comments on commit 8045ecc

Please sign in to comment.