(self, code, exitcode, callback=None)
| 3208 | |
| 3209 | @warnings_helper.ignore_fork_in_thread_deprecation_warnings() |
| 3210 | def check_waitpid(self, code, exitcode, callback=None): |
| 3211 | if sys.platform == 'win32': |
| 3212 | # On Windows, os.spawnv() simply joins arguments with spaces: |
| 3213 | # arguments need to be quoted |
| 3214 | args = [f'"{sys.executable}"', '-c', f'"{code}"'] |
| 3215 | else: |
| 3216 | args = [sys.executable, '-c', code] |
| 3217 | pid = os.spawnv(os.P_NOWAIT, sys.executable, args) |
| 3218 | |
| 3219 | if callback is not None: |
| 3220 | callback(pid) |
| 3221 | |
| 3222 | # don't use support.wait_process() to test directly os.waitpid() |
| 3223 | # and os.waitstatus_to_exitcode() |
| 3224 | pid2, status = os.waitpid(pid, 0) |
| 3225 | self.assertEqual(os.waitstatus_to_exitcode(status), exitcode) |
| 3226 | self.assertEqual(pid2, pid) |
| 3227 | |
| 3228 | def test_waitpid(self): |
| 3229 | self.check_waitpid(code='pass', exitcode=0) |
no test coverage detected