From: Victor Stinner Date: Mon, 28 Jul 2014 23:13:39 +0000 (+0200) Subject: Issue #18174: Fix leak of file descriptor in test_tempfile X-Git-Tag: v3.4.2rc1~173 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c61c170b419be5896608baf47ca3737b94cc15da;p=python Issue #18174: Fix leak of file descriptor in test_tempfile --- diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py index b23c19fad6..ec975f82a6 100644 --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -762,8 +762,10 @@ class TestNamedTemporaryFile(BaseTestCase): def test_no_leak_fd(self): # Issue #21058: don't leak file descriptor when io.open() fails closed = [] + os_close = os.close def close(fd): closed.append(fd) + os_close(fd) with mock.patch('os.close', side_effect=close): with mock.patch('io.open', side_effect=ValueError): @@ -1076,8 +1078,10 @@ if tempfile.NamedTemporaryFile is not tempfile.TemporaryFile: def test_no_leak_fd(self): # Issue #21058: don't leak file descriptor when io.open() fails closed = [] + os_close = os.close def close(fd): closed.append(fd) + os_close(fd) with mock.patch('os.close', side_effect=close): with mock.patch('io.open', side_effect=ValueError):