[Python-checkins] cpython (2.7): Issue #18174: Fix fd leaks in tests.
richard.oudkerk
python-checkins at python.org
Mon Jun 10 17:33:15 CEST 2013
http://hg.python.org/cpython/rev/a7381fe515e8
changeset: 84080:a7381fe515e8
branch: 2.7
parent: 84074:4d1e4bc6c5b5
user: Richard Oudkerk <shibturn at gmail.com>
date: Mon Jun 10 16:27:45 2013 +0100
summary:
Issue #18174: Fix fd leaks in tests.
files:
Lib/test/test_openpty.py | 2 ++
Lib/test/test_subprocess.py | 3 ++-
Lib/test/test_uuid.py | 1 +
3 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_openpty.py b/Lib/test/test_openpty.py
--- a/Lib/test/test_openpty.py
+++ b/Lib/test/test_openpty.py
@@ -10,6 +10,8 @@
class OpenptyTest(unittest.TestCase):
def test(self):
master, slave = os.openpty()
+ self.addCleanup(os.close, master)
+ self.addCleanup(os.close, slave)
if not os.isatty(slave):
self.fail("Slave-end of pty is not a terminal.")
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -806,7 +806,8 @@
self._testcase.assertNotIn(
fd, (p2cwrite, c2pread, errread))
finally:
- map(os.close, devzero_fds)
+ for fd in devzero_fds:
+ os.close(fd)
@unittest.skipIf(not os.path.exists("/dev/zero"), "/dev/zero required.")
def test_preexec_errpipe_does_not_double_close_pipes(self):
diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -448,6 +448,7 @@
else:
os.close(fds[1])
+ self.addCleanup(os.close, fds[0])
parent_value = uuid.uuid4().hex
os.waitpid(pid, 0)
child_value = os.read(fds[0], 100)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list