added non-exclusive fd for test

This commit is contained in:
wiredfool 2017-04-04 00:27:20 -07:00
parent 06b61f4e5b
commit f95c158933

View File

@ -469,8 +469,8 @@ class TestFileTiff(PillowTestCase):
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
def test_close_on_load_exclusive(self):
# similar to test_fd_leak, but runs on unixlike os
tmpfile = self.tempfile("temp.tif")
with Image.open("Tests/images/uint16_1_4660.tif") as im:
@ -482,6 +482,19 @@ class TestFileTiff(PillowTestCase):
im.load()
self.assertTrue(fp.closed)
def test_close_on_load_nonexclusive(self):
tmpfile = self.tempfile("temp.tif")
with Image.open("Tests/images/uint16_1_4660.tif") as im:
im.save(tmpfile)
f = open(tmpfile, 'rb')
im = Image.open(f)
fp = im.fp
self.assertFalse(fp.closed)
im.load()
self.assertFalse(fp.closed)
@unittest.skipUnless(sys.platform.startswith('win32'), "Windows only")