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

Method check_waitpid

Lib/test/test_os.py:3525–3541  ·  view source on GitHub ↗
(self, code, exitcode, callback=None)

Source from the content-addressed store, hash-verified

3523 self.assertEqual(int(stdout), os.getpid())
3524
3525 def check_waitpid(self, code, exitcode, callback=None):
3526 if sys.platform == 'win32':
3527 # On Windows, os.spawnv() simply joins arguments with spaces:
3528 # arguments need to be quoted
3529 args = [f'"{sys.executable}"', '-c', f'"{code}"']
3530 else:
3531 args = [sys.executable, '-c', code]
3532 pid = os.spawnv(os.P_NOWAIT, sys.executable, args)
3533
3534 if callback is not None:
3535 callback(pid)
3536
3537 # don't use support.wait_process() to test directly os.waitpid()
3538 # and os.waitstatus_to_exitcode()
3539 pid2, status = os.waitpid(pid, 0)
3540 self.assertEqual(os.waitstatus_to_exitcode(status), exitcode)
3541 self.assertEqual(pid2, pid)
3542
3543 def test_waitpid(self):
3544 self.check_waitpid(code='pass', exitcode=0)

Callers 4

test_waitpidMethod · 0.95
test_waitpid_windowsMethod · 0.95

Calls 2

callbackFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected