mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-10 00:20:57 +03:00
added unix test for fd leak
This commit is contained in:
parent
e4e0e0d2bf
commit
900c5e5bf2
|
@ -469,6 +469,22 @@ class TestFileTiff(PillowTestCase):
|
||||||
|
|
||||||
self.assertEqual(b'Dummy value', reloaded.info['icc_profile'])
|
self.assertEqual(b'Dummy value', reloaded.info['icc_profile'])
|
||||||
|
|
||||||
|
def test_close_on_load(self):
|
||||||
|
# same as test_fd_leak, but runs on unixlike os
|
||||||
|
tmpfile = self.tempfile("temp.tif")
|
||||||
|
import os
|
||||||
|
|
||||||
|
with Image.open("Tests/images/uint16_1_4660.tif") as im:
|
||||||
|
im.save(tmpfile)
|
||||||
|
|
||||||
|
im = Image.open(tmpfile)
|
||||||
|
fp = im.fp
|
||||||
|
self.assertFalse(fp.closed)
|
||||||
|
im.load()
|
||||||
|
self.assertTrue(fp.closed)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(sys.platform.startswith('win32'), "Windows only")
|
@unittest.skipUnless(sys.platform.startswith('win32'), "Windows only")
|
||||||
class TestFileTiffW32(PillowTestCase):
|
class TestFileTiffW32(PillowTestCase):
|
||||||
def test_fd_leak(self):
|
def test_fd_leak(self):
|
||||||
|
@ -479,8 +495,11 @@ class TestFileTiffW32(PillowTestCase):
|
||||||
im.save(tmpfile)
|
im.save(tmpfile)
|
||||||
|
|
||||||
im = Image.open(tmpfile)
|
im = Image.open(tmpfile)
|
||||||
|
fp = im.fp
|
||||||
|
self.assertFalse(fp.closed)
|
||||||
self.assertRaises(Exception, lambda: os.remove(tmpfile))
|
self.assertRaises(Exception, lambda: os.remove(tmpfile))
|
||||||
im.load()
|
im.load()
|
||||||
|
self.assertTrue(fp.closed)
|
||||||
# this should not fail, as load should have closed the file.
|
# this should not fail, as load should have closed the file.
|
||||||
os.remove(tmpfile)
|
os.remove(tmpfile)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user