@@ -124,6 +124,23 @@ def test_negative_stride(self):
124124 with pytest .raises (OSError ):
125125 p .close ()
126126
127+ def test_no_format (self ):
128+ buf = BytesIO (b"\x00 " * 255 )
129+
130+ class DummyImageFile (ImageFile .ImageFile ):
131+ def _open (self ):
132+ self .mode = "RGB"
133+ self ._size = (1 , 1 )
134+
135+ im = DummyImageFile (buf )
136+ assert im .format is None
137+ assert im .get_format_mimetype () is None
138+
139+ def test_oserror (self ):
140+ im = Image .new ("RGB" , (1 , 1 ))
141+ with pytest .raises (OSError ):
142+ im .save (BytesIO (), "JPEG2000" , num_resolutions = 2 )
143+
127144 def test_truncated (self ):
128145 b = BytesIO (
129146 b"BM000000000000" # head_data
@@ -258,15 +275,3 @@ def test_oversize(self):
258275 im .tile = [("MOCK" , (xoff , yoff , xoff + xsize , yoff + ysize + 100 ), 32 , None )]
259276 with pytest .raises (ValueError ):
260277 im .load ()
261-
262- def test_no_format (self ):
263- buf = BytesIO (b"\x00 " * 255 )
264-
265- im = MockImageFile (buf )
266- assert im .format is None
267- assert im .get_format_mimetype () is None
268-
269- def test_oserror (self ):
270- im = Image .new ("RGB" , (1 , 1 ))
271- with pytest .raises (OSError ):
272- im .save (BytesIO (), "JPEG2000" , num_resolutions = 2 )
0 commit comments