File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import io
34from pathlib import Path
45
56import pytest
@@ -36,6 +37,28 @@ def test_sanity(tmp_path: Path) -> None:
3637 im .save (f )
3738
3839
40+ def test_bad_image_size () -> None :
41+ with open ("Tests/images/pil184.pcx" , "rb" ) as fp :
42+ data = fp .read ()
43+ data = data [:4 ] + b"\xff \xff " + data [6 :]
44+
45+ b = io .BytesIO (data )
46+ with pytest .raises (SyntaxError , match = "bad PCX image size" ):
47+ with PcxImagePlugin .PcxImageFile (b ):
48+ pass
49+
50+
51+ def test_unknown_mode () -> None :
52+ with open ("Tests/images/pil184.pcx" , "rb" ) as fp :
53+ data = fp .read ()
54+ data = data [:3 ] + b"\xff " + data [4 :]
55+
56+ b = io .BytesIO (data )
57+ with pytest .raises (OSError , match = "unknown PCX mode" ):
58+ with Image .open (b ):
59+ pass
60+
61+
3962def test_invalid_file () -> None :
4063 invalid_file = "Tests/images/flower.jpg"
4164
You can’t perform that action at this time.
0 commit comments