File tree Expand file tree Collapse file tree 4 files changed +19
-9
lines changed
Expand file tree Collapse file tree 4 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import io
34import warnings
45
56import pytest
@@ -132,6 +133,15 @@ def test_eoferror() -> None:
132133 im .seek (n_frames - 1 )
133134
134135
136+ def test_missing_frame_size () -> None :
137+ with open (animated_test_file , "rb" ) as fp :
138+ data = fp .read ()
139+ data = data [:6188 ]
140+ with Image .open (io .BytesIO (data )) as im :
141+ with pytest .raises (EOFError , match = "missing frame size" ):
142+ im .seek (1 )
143+
144+
135145def test_seek_tell () -> None :
136146 with Image .open (animated_test_file ) as im :
137147 layer_number = im .tell ()
Original file line number Diff line number Diff line change @@ -317,12 +317,12 @@ def test_grayscale_four_channels() -> None:
317317 with open ("Tests/images/rgb_trns_ycbc.jp2" , "rb" ) as fp :
318318 data = fp .read ()
319319
320- # Change color space to OPJ_CLRSPC_GRAY
321- data = data [:76 ] + b"\x11 " + data [77 :]
320+ # Change color space to OPJ_CLRSPC_GRAY
321+ data = data [:76 ] + b"\x11 " + data [77 :]
322322
323- with Image .open (BytesIO (data )) as im :
324- im .load ()
325- assert im .mode == "RGBA"
323+ with Image .open (BytesIO (data )) as im :
324+ im .load ()
325+ assert im .mode == "RGBA"
326326
327327
328328@pytest .mark .skipif (
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def test_sanity(tmp_path: Path) -> None:
4040def test_bad_image_size () -> None :
4141 with open ("Tests/images/pil184.pcx" , "rb" ) as fp :
4242 data = fp .read ()
43- data = data [:4 ] + b"\xff \xff " + data [6 :]
43+ data = data [:4 ] + b"\xff \xff " + data [6 :]
4444
4545 b = io .BytesIO (data )
4646 with pytest .raises (SyntaxError , match = "bad PCX image size" ):
@@ -51,7 +51,7 @@ def test_bad_image_size() -> None:
5151def test_unknown_mode () -> None :
5252 with open ("Tests/images/pil184.pcx" , "rb" ) as fp :
5353 data = fp .read ()
54- data = data [:3 ] + b"\xff " + data [4 :]
54+ data = data [:3 ] + b"\xff " + data [4 :]
5555
5656 b = io .BytesIO (data )
5757 with pytest .raises (OSError , match = "unknown PCX mode" ):
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ def test_sanity() -> None:
2020def test_zero_width_chars () -> None :
2121 with open (filename , "rb" ) as fp :
2222 data = fp .read ()
23- data = data [:2650 ] + b"\x00 \x00 " + data [2652 :]
24- BdfFontFile .BdfFontFile (io .BytesIO (data ))
23+ data = data [:2650 ] + b"\x00 \x00 " + data [2652 :]
24+ BdfFontFile .BdfFontFile (io .BytesIO (data ))
2525
2626
2727def test_invalid_file () -> None :
You can’t perform that action at this time.
0 commit comments