Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions Tests/test_file_psd.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_seek_tell() -> None:

im.seek(2)
layer_number = im.tell()
assert layer_number == 2
assert layer_number == 2


def test_seek_eoferror() -> None:
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_icc_profile() -> None:
assert "icc_profile" in im.info

icc_profile = im.info["icc_profile"]
assert len(icc_profile) == 3144
assert len(icc_profile) == 3144


def test_no_icc_profile() -> None:
Expand All @@ -158,17 +158,16 @@ def test_combined_larger_than_size() -> None:


@pytest.mark.parametrize(
"test_file,raises",
"test_file",
[
("Tests/images/timeout-c8efc3fded6426986ba867a399791bae544f59bc.psd", OSError),
("Tests/images/timeout-dedc7a4ebd856d79b4359bbcc79e8ef231ce38f6.psd", OSError),
"Tests/images/timeout-c8efc3fded6426986ba867a399791bae544f59bc.psd",
"Tests/images/timeout-dedc7a4ebd856d79b4359bbcc79e8ef231ce38f6.psd",
],
)
def test_crashes(test_file: str, raises: type[Exception]) -> None:
with open(test_file, "rb") as f:
with pytest.raises(raises):
with Image.open(f):
pass
def test_crashes(test_file: str) -> None:
with pytest.raises(OSError):
with Image.open(test_file):
pass


@pytest.mark.parametrize(
Expand All @@ -179,8 +178,7 @@ def test_crashes(test_file: str, raises: type[Exception]) -> None:
],
)
def test_layer_crashes(test_file: str) -> None:
with open(test_file, "rb") as f:
with Image.open(f) as im:
assert isinstance(im, PsdImagePlugin.PsdImageFile)
with pytest.raises(SyntaxError):
im.layers
with Image.open(test_file) as im:
assert isinstance(im, PsdImagePlugin.PsdImageFile)
with pytest.raises(SyntaxError):
im.layers
Loading