mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
(Merge 3.4) Issue #18174: Fix leak of file descriptor in test_tempfile
This commit is contained in:
commit
6b08235a03
1 changed files with 4 additions and 0 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue