File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
+ import io
3
4
from pathlib import Path
4
5
5
6
import pytest
@@ -36,6 +37,28 @@ def test_sanity(tmp_path: Path) -> None:
36
37
im .save (f )
37
38
38
39
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
+
39
62
def test_invalid_file () -> None :
40
63
invalid_file = "Tests/images/flower.jpg"
41
64
You can’t perform that action at this time.
0 commit comments