(Merge 3.4) Issue #11453, #18174: Fix leak of file descriptor in test_asyncore

This commit is contained in:
Victor Stinner 2014-07-29 01:01:43 +02:00
commit 1bcab66811
1 changed files with 4 additions and 0 deletions

View File

@ -417,6 +417,8 @@ class FileWrapperTest(unittest.TestCase):
# Issue #11453
fd = os.open(support.TESTFN, os.O_RDONLY)
f = asyncore.file_wrapper(fd)
os.close(fd)
with support.check_warnings(('', ResourceWarning)):
f = None
support.gc_collect()
@ -424,6 +426,8 @@ class FileWrapperTest(unittest.TestCase):
def test_close_twice(self):
fd = os.open(support.TESTFN, os.O_RDONLY)
f = asyncore.file_wrapper(fd)
os.close(fd)
f.close()
self.assertEqual(f.fd, -1)
# calling close twice should not fail