bpo-18174: Fix file descriptor leaks in tests (GH-7408)
* 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.
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index 5c111a2..2efb836 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -821,6 +821,7 @@
old_fdopen = os.fdopen
closed = []
def close(fd):
+ old_close(fd)
closed.append(fd)
def fdopen(*args):
raise ValueError()