File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -33,14 +33,22 @@ def test_rgb() -> None:
33
33
assert_image_similar (im , hopper (), 16 )
34
34
35
35
36
- def test_cannot_read () -> None :
36
+ def test_truncated_header () -> None :
37
+ data = b"/* XPM */"
38
+ with pytest .raises (SyntaxError , match = "broken XPM file" ):
39
+ with XpmImagePlugin .XpmImageFile (BytesIO (data )):
40
+ pass
41
+
42
+
43
+ def test_cannot_read_color () -> None :
37
44
with open (TEST_FILE , "rb" ) as fp :
38
45
data = fp .read ().split (b"#" )[0 ]
39
46
with pytest .raises (ValueError , match = "cannot read this XPM file" ):
40
- with Image .open (BytesIO (data )) as im :
47
+ with Image .open (BytesIO (data )):
41
48
pass
49
+
42
50
with pytest .raises (ValueError , match = "cannot read this XPM file" ):
43
- with Image .open (BytesIO (data + b"invalid" )) as im :
51
+ with Image .open (BytesIO (data + b"invalid" )):
44
52
pass
45
53
46
54
You can’t perform that action at this time.
0 commit comments