MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_pass_fds

Method test_pass_fds

Lib/test/test_subprocess.py:3148–3179  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 12

communicateMethod · 0.95
setFunction · 0.85
strFunction · 0.85
addCleanupMethod · 0.80
set_inheritableMethod · 0.80
assertInMethod · 0.80
assertFalseMethod · 0.80
assertWarnsMethod · 0.80
pipeMethod · 0.45
updateMethod · 0.45
splitMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected