]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #18174: Fix fd leaks in tests.
authorRichard Oudkerk <shibturn@gmail.com>
Mon, 10 Jun 2013 15:27:45 +0000 (16:27 +0100)
committerRichard Oudkerk <shibturn@gmail.com>
Mon, 10 Jun 2013 15:27:45 +0000 (16:27 +0100)
Lib/test/test_openpty.py
Lib/test/test_subprocess.py
Lib/test/test_uuid.py

index 20c4fe239c2f21ccc4474dfc820aec71cfb6784f..4b34b3a3c779702fcbcae7462a88efd05dbc55b6 100644 (file)
@@ -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.")
 
index e89d84f490352966d35c82095735905ee5759aa6..f43b51caf832e20f074828bdc221c5b55bcd18aa 100644 (file)
@@ -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):
index 6fe2fe5edb3108f396de4356695cf1736e463107..9de3d789c5e2952107c28ebe1ab8d2f1b70a20a0 100644 (file)
@@ -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)