* test_tempfile.test_no_leak_fd() mocks os.close() but it doesn't
call the original os.close() method and so leaks an open file
descriptor. Fix the test by calling the original os.close()
function.
* test_posix.test_fdopen_directory(): close the directory file
descriptor when the test completes.
def test_fdopen_directory(self):
try:
fd = os.open('.', os.O_RDONLY)
+ self.addCleanup(os.close, fd)
except OSError as e:
self.assertEqual(e.errno, errno.EACCES)
self.skipTest("system cannot open directories")
old_fdopen = os.fdopen
closed = []
def close(fd):
+ old_close(fd)
closed.append(fd)
def fdopen(*args):
raise ValueError()