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