mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-12 21:34:13 +03:00
Merge pull request #8797 from radarhere/pcx
Improved PcxImagePlugin test coverage
This commit is contained in:
commit
c23bf05201
|
@ -1,5 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
@ -36,6 +37,28 @@ def test_sanity(tmp_path: Path) -> None:
|
|||
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
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
def test_invalid_file() -> None:
|
||||
invalid_file = "Tests/images/flower.jpg"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user