From b73b4a7b6315bd5649a2c61660bfb56089c96c3d Mon Sep 17 00:00:00 2001 From: wiredfool Date: Thu, 27 Mar 2014 22:17:27 -0700 Subject: [PATCH] Tests for #526 --- Tests/test_file_libtiff.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index a94257bc0..79abe5961 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -1,4 +1,5 @@ from tester import * +import warnings from PIL import Image, TiffImagePlugin @@ -34,6 +35,7 @@ def test_g4_tiff(): assert_equal(im.size, (500,500)) _assert_noerr(im) + im = None def test_g4_large(): file = "Tests/images/pport_g4.tif" @@ -295,3 +297,15 @@ def xtest_bw_compression_wRGB(): assert_exception(IOError, lambda: im.save(out, compression='group3')) assert_exception(IOError, lambda: im.save(out, compression='group4')) +def test_fp_leak(): + import os + + im = Image.open("Tests/images/lena_g4_500.tif") + fn = im.fp.fileno() + + assert_no_exception(lambda: os.fstat(fn)) + im.load() # this should close it. + assert_exception(OSError, lambda: os.fstat(fn)) + im = None # this should force even more closed. + assert_exception(OSError, lambda: os.fstat(fn)) + assert_exception(OSError, lambda: os.close(fn))