Tests for issue #1651

This commit is contained in:
wiredfool 2016-09-29 22:29:19 +01:00
parent 41cbd4f4d3
commit b81da5a322
2 changed files with 18 additions and 0 deletions

BIN
Tests/images/g4-multi.tiff Normal file

Binary file not shown.

View File

@ -505,6 +505,24 @@ class TestFileLibTiff(LibTiffTestCase):
# Should not divide by zero
im.save(outfile)
def test_fd_duplication(self):
# https://github.com/python-pillow/Pillow/issues/1651
tmpfile = self.tempfile("temp.tif")
with open(tmpfile, 'wb') as f:
with open("Tests/images/g4-multi.tiff", 'rb') as src:
f.write(src.read())
im = Image.open(tmpfile)
count = im.n_frames
im.close()
try:
os.remove(tmpfile) # Windows PermissionError here!
except:
self.fail("Should not get permission error here")
if __name__ == '__main__':
unittest.main()