mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Changed EOFError tests
This commit is contained in:
parent
78c62727d3
commit
f61b70aa8f
|
@ -42,15 +42,14 @@ class TestFileDcx(PillowTestCase):
|
|||
|
||||
def test_eoferror(self):
|
||||
im = Image.open(TEST_FILE)
|
||||
|
||||
n_frames = im.n_frames
|
||||
while True:
|
||||
n_frames -= 1
|
||||
try:
|
||||
im.seek(n_frames)
|
||||
break
|
||||
except EOFError:
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
# Test seeking past the last frame
|
||||
self.assertRaises(EOFError, im.seek, n_frames)
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
# Test that seeking to the last frame does not raise an error
|
||||
im.seek(n_frames-1)
|
||||
|
||||
def test_seek_too_far(self):
|
||||
# Arrange
|
||||
|
|
|
@ -54,24 +54,14 @@ class TestFileFli(PillowTestCase):
|
|||
|
||||
def test_eoferror(self):
|
||||
im = Image.open(animated_test_file)
|
||||
|
||||
n_frames = im.n_frames
|
||||
while True:
|
||||
n_frames -= 1
|
||||
try:
|
||||
im.seek(n_frames)
|
||||
break
|
||||
except EOFError:
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
def test_seek_outside(self):
|
||||
# Test negative seek
|
||||
im = Image.open(static_test_file)
|
||||
im.seek(-1)
|
||||
self.assertEqual(im.tell(), 0)
|
||||
# Test seeking past the last frame
|
||||
self.assertRaises(EOFError, im.seek, n_frames)
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
# Test seek past end of file
|
||||
self.assertRaises(EOFError, im.seek, 2)
|
||||
# Test that seeking to the last frame does not raise an error
|
||||
im.seek(n_frames-1)
|
||||
|
||||
def test_seek_tell(self):
|
||||
im = Image.open(animated_test_file)
|
||||
|
@ -91,6 +81,10 @@ class TestFileFli(PillowTestCase):
|
|||
layer_number = im.tell()
|
||||
self.assertEqual(layer_number, 2)
|
||||
|
||||
im.seek(1)
|
||||
layer_number = im.tell()
|
||||
self.assertEqual(layer_number, 1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -223,15 +223,14 @@ class TestFileGif(PillowTestCase):
|
|||
|
||||
def test_eoferror(self):
|
||||
im = Image.open(TEST_GIF)
|
||||
|
||||
n_frames = im.n_frames
|
||||
while True:
|
||||
n_frames -= 1
|
||||
try:
|
||||
im.seek(n_frames)
|
||||
break
|
||||
except EOFError:
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
# Test seeking past the last frame
|
||||
self.assertRaises(EOFError, im.seek, n_frames)
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
# Test that seeking to the last frame does not raise an error
|
||||
im.seek(n_frames-1)
|
||||
|
||||
def test_dispose_none(self):
|
||||
img = Image.open("Tests/images/dispose_none.gif")
|
||||
|
|
|
@ -32,15 +32,14 @@ class TestFileIm(PillowTestCase):
|
|||
|
||||
def test_eoferror(self):
|
||||
im = Image.open(TEST_IM)
|
||||
|
||||
n_frames = im.n_frames
|
||||
while True:
|
||||
n_frames -= 1
|
||||
try:
|
||||
im.seek(n_frames)
|
||||
break
|
||||
except EOFError:
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
# Test seeking past the last frame
|
||||
self.assertRaises(EOFError, im.seek, n_frames)
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
# Test that seeking to the last frame does not raise an error
|
||||
im.seek(n_frames-1)
|
||||
|
||||
def test_roundtrip(self):
|
||||
for mode in ["RGB", "P"]:
|
||||
|
|
|
@ -102,15 +102,14 @@ class TestFileMpo(PillowTestCase):
|
|||
|
||||
def test_eoferror(self):
|
||||
im = Image.open("Tests/images/sugarshack.mpo")
|
||||
|
||||
n_frames = im.n_frames
|
||||
while True:
|
||||
n_frames -= 1
|
||||
try:
|
||||
im.seek(n_frames)
|
||||
break
|
||||
except EOFError:
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
# Test seeking past the last frame
|
||||
self.assertRaises(EOFError, im.seek, n_frames)
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
# Test that seeking to the last frame does not raise an error
|
||||
im.seek(n_frames-1)
|
||||
|
||||
def test_image_grab(self):
|
||||
for test_file in test_files:
|
||||
|
|
|
@ -250,15 +250,14 @@ class TestFileTiff(PillowTestCase):
|
|||
|
||||
def test_eoferror(self):
|
||||
im = Image.open('Tests/images/multipage-lastframe.tif')
|
||||
|
||||
n_frames = im.n_frames
|
||||
while True:
|
||||
n_frames -= 1
|
||||
try:
|
||||
im.seek(n_frames)
|
||||
break
|
||||
except EOFError:
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
# Test seeking past the last frame
|
||||
self.assertRaises(EOFError, im.seek, n_frames)
|
||||
self.assertLess(im.tell(), n_frames)
|
||||
|
||||
# Test that seeking to the last frame does not raise an error
|
||||
im.seek(n_frames-1)
|
||||
|
||||
def test_multipage(self):
|
||||
# issue #862
|
||||
|
|
Loading…
Reference in New Issue
Block a user