(self)
| 3145 | # descriptor is invalid, and read or write raise an error. |
| 3146 | @support.requires_mac_ver(10, 5) |
| 3147 | def test_pass_fds(self): |
| 3148 | fd_status = support.findfile("fd_status.py", subdir="subprocessdata") |
| 3149 | |
| 3150 | open_fds = set() |
| 3151 | |
| 3152 | for x in range(5): |
| 3153 | fds = os.pipe() |
| 3154 | self.addCleanup(os.close, fds[0]) |
| 3155 | self.addCleanup(os.close, fds[1]) |
| 3156 | os.set_inheritable(fds[0], True) |
| 3157 | os.set_inheritable(fds[1], True) |
| 3158 | open_fds.update(fds) |
| 3159 | |
| 3160 | for fd in open_fds: |
| 3161 | p = subprocess.Popen([sys.executable, fd_status], |
| 3162 | stdout=subprocess.PIPE, close_fds=True, |
| 3163 | pass_fds=(fd, )) |
| 3164 | output, ignored = p.communicate() |
| 3165 | |
| 3166 | remaining_fds = set(map(int, output.split(b','))) |
| 3167 | to_be_closed = open_fds - {fd} |
| 3168 | |
| 3169 | self.assertIn(fd, remaining_fds, "fd to be passed not passed") |
| 3170 | self.assertFalse(remaining_fds & to_be_closed, |
| 3171 | "fd to be closed passed") |
| 3172 | |
| 3173 | # pass_fds overrides close_fds with a warning. |
| 3174 | with self.assertWarns(RuntimeWarning) as context: |
| 3175 | self.assertFalse(subprocess.call( |
| 3176 | ZERO_RETURN_CMD, |
| 3177 | close_fds=False, pass_fds=(fd, ))) |
| 3178 | self.assertIn('overriding close_fds', str(context.warning)) |
| 3179 | |
| 3180 | def test_pass_fds_inheritable(self): |
| 3181 | script = support.findfile("fd_status.py", subdir="subprocessdata") |
nothing calls this directly
no test coverage detected