Commit 045e4579 authored by Richard Oudkerk's avatar Richard Oudkerk

Issue #18174: Fix fd leaks in tests.

parent 0e6283e6
......@@ -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.")
......
......@@ -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):
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment