From f95c15893335774f4adbd44f8f8c79612aecfec7 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Tue, 4 Apr 2017 00:27:20 -0700 Subject: [PATCH] added non-exclusive fd for test --- Tests/test_file_tiff.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 81f135115..1e182fb1a 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -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")