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
23 changes: 23 additions & 0 deletions Tests/test_file_pcx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import io
from pathlib import Path

import pytest
Expand Down Expand Up @@ -36,6 +37,28 @@
im.save(f)


def test_bad_image_size() -> None:
with open("Tests/images/pil184.pcx", "rb") as fp:
data = fp.read()
data = data[:4] + b"\xff\xff" + data[6:]

b = io.BytesIO(data)
with pytest.raises(SyntaxError, match="bad PCX image size"):
with PcxImagePlugin.PcxImageFile(b):
pass

Check warning on line 48 in Tests/test_file_pcx.py

View check run for this annotation

Codecov / codecov/patch

Tests/test_file_pcx.py#L48

Added line #L48 was not covered by tests


def test_unknown_mode() -> None:
with open("Tests/images/pil184.pcx", "rb") as fp:
data = fp.read()
data = data[:3] + b"\xff" + data[4:]

b = io.BytesIO(data)
with pytest.raises(OSError, match="unknown PCX mode"):
with Image.open(b):
pass

Check warning on line 59 in Tests/test_file_pcx.py

View check run for this annotation

Codecov / codecov/patch

Tests/test_file_pcx.py#L59

Added line #L59 was not covered by tests


def test_invalid_file() -> None:
invalid_file = "Tests/images/flower.jpg"

Expand Down
Loading