Skip to content

Commit

Permalink
Moved unrelated tests out of TestPyDecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 24, 2022
1 parent b3599de commit 0919c57
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Tests/test_imagefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ def test_negative_stride(self):
with pytest.raises(OSError):
p.close()

def test_no_format(self):
buf = BytesIO(b"\x00" * 255)

class DummyImageFile(ImageFile.ImageFile):
def _open(self):
self.mode = "RGB"
self._size = (1, 1)

im = DummyImageFile(buf)
assert im.format is None
assert im.get_format_mimetype() is None

def test_oserror(self):
im = Image.new("RGB", (1, 1))
with pytest.raises(OSError):
im.save(BytesIO(), "JPEG2000", num_resolutions=2)

def test_truncated(self):
b = BytesIO(
b"BM000000000000" # head_data
Expand Down Expand Up @@ -258,15 +275,3 @@ def test_oversize(self):
im.tile = [("MOCK", (xoff, yoff, xoff + xsize, yoff + ysize + 100), 32, None)]
with pytest.raises(ValueError):
im.load()

def test_no_format(self):
buf = BytesIO(b"\x00" * 255)

im = MockImageFile(buf)
assert im.format is None
assert im.get_format_mimetype() is None

def test_oserror(self):
im = Image.new("RGB", (1, 1))
with pytest.raises(OSError):
im.save(BytesIO(), "JPEG2000", num_resolutions=2)

0 comments on commit 0919c57

Please sign in to comment.