summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2013-06-10 16:27:45 +0100
committerRichard Oudkerk <shibturn@gmail.com>2013-06-10 16:27:45 +0100
commit045e4579928768c0c40ae174aaa3bec1a53dc431 (patch)
treea0eced1d868f205a6aef4b2c13868ea22271968b /Lib/test
parent0e6283e68a9d6035e68a91904f13733df512dbce (diff)
downloadcpython-git-045e4579928768c0c40ae174aaa3bec1a53dc431.tar.gz
Issue #18174: Fix fd leaks in tests.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_openpty.py2
-rw-r--r--Lib/test/test_subprocess.py3
-rw-r--r--Lib/test/test_uuid.py1
3 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_openpty.py b/Lib/test/test_openpty.py
index 20c4fe239c..4b34b3a3c7 100644
--- a/Lib/test/test_openpty.py
+++ b/Lib/test/test_openpty.py
@@ -10,6 +10,8 @@ if not hasattr(os, "openpty"):
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
index e89d84f490..f43b51caf8 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -806,7 +806,8 @@ class POSIXProcessTestCase(BaseTestCase):
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
index 6fe2fe5edb..9de3d789c5 100644
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -448,6 +448,7 @@ class TestUUID(unittest.TestCase):
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)