summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-07-28 23:15:22 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-07-28 23:15:22 (GMT)
commit6b08235a034b42c9b5bd9408ed64022fcab56ef6 (patch)
tree3c2da916d84f04f84035ba96ba652b0a1a2a7303
parent1bcab668112e9b3f17ad5e85e47f41137d997623 (diff)
parentc61c170b419be5896608baf47ca3737b94cc15da (diff)
downloadcpython-6b08235a034b42c9b5bd9408ed64022fcab56ef6.zip
cpython-6b08235a034b42c9b5bd9408ed64022fcab56ef6.tar.gz
cpython-6b08235a034b42c9b5bd9408ed64022fcab56ef6.tar.bz2
(Merge 3.4) Issue #18174: Fix leak of file descriptor in test_tempfile
-rw-r--r--Lib/test/test_tempfile.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index b23c19f..ec975f8 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):