Lines Matching defs:subprocess

8 import subprocess
53 raise unittest.SkipTest("test module requires subprocess")
79 subprocess.run([shell_true]).returncode == 0):
92 # subprocess._active is not used on Windows and is set to None.
93 for inst in subprocess._active:
95 subprocess._cleanup()
97 subprocess._active, "subprocess._active not empty"
107 class PopenExecuteChildRaises(subprocess.Popen):
108 """Popen subclass for testing cleanup of subprocess.PIPE filehandles when
118 p = subprocess.Popen(ZERO_RETURN_CMD,
119 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
120 stderr=subprocess.PIPE)
132 p = subprocess.Popen(ZERO_RETURN_CMD,
133 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
134 stderr=subprocess.PIPE, bufsize=0)
147 rc = subprocess.call([sys.executable, "-c",
154 # killed, this call will deadlock since subprocess.call waits for the
156 self.assertRaises(subprocess.TimeoutExpired, subprocess.call,
162 rc = subprocess.check_call(ZERO_RETURN_CMD)
167 with self.assertRaises(subprocess.CalledProcessError) as c:
168 subprocess.check_call([sys.executable, "-c",
174 output = subprocess.check_output(
180 subprocess.check_output([], stdout=None)
184 subprocess.check_output([], check=False)
188 with self.assertRaises(subprocess.CalledProcessError) as c:
189 subprocess.check_output(
195 output = subprocess.check_output(
197 stderr=subprocess.STDOUT)
206 output = subprocess.check_output(
214 output = subprocess.check_output(
222 output = subprocess.check_output(
229 output = subprocess.check_output(
236 output = subprocess.check_output(
243 output = subprocess.check_output(
251 output = subprocess.check_output(
264 output = subprocess.check_output(
273 with self.assertRaises(subprocess.TimeoutExpired) as c:
274 output = subprocess.check_output(
290 rc = subprocess.call([sys.executable, "-c",
300 self.assertRaises(TypeError, subprocess.Popen, invalid_arg_name=1)
301 argcount = subprocess.Popen.__init__.__code__.co_argcount
303 self.assertRaises(TypeError, subprocess.Popen, *too_many_args)
308 p = subprocess.Popen([sys.executable, "-c", 'print("banana")'],
309 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
318 # subprocess in a subprocess:
320 # \-- subprocess created by this test (parent)
321 # \-- subprocess created by the parent subprocess (child)
326 code = ('import sys; from subprocess import Popen, PIPE;'
330 p = subprocess.Popen([sys.executable, "-c", code],
331 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
340 p = subprocess.Popen([sys.executable, "-c", 'print("banana")'],
341 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
351 p = subprocess.Popen(args, **kwargs)
423 p = subprocess.Popen([python_arg, "-c",
429 stdout=subprocess.PIPE,
463 self.assertRaises(FileNotFoundError, subprocess.Popen,
465 self.assertRaises(FileNotFoundError, subprocess.Popen,
480 self.assertRaises(FileNotFoundError, subprocess.Popen,
482 self.assertRaises(FileNotFoundError, subprocess.Popen,
498 self.assertRaises(FileNotFoundError, subprocess.Popen,
523 p = subprocess.Popen([sys.executable, "-c",
525 stdin=subprocess.PIPE)
538 p = subprocess.Popen([sys.executable, "-c",
550 p = subprocess.Popen([sys.executable, "-c",
558 p = subprocess.Popen([sys.executable, "-c",
560 stdout=subprocess.PIPE)
569 p = subprocess.Popen([sys.executable, "-c",
580 p = subprocess.Popen([sys.executable, "-c",
589 p = subprocess.Popen([sys.executable, "-c",
591 stderr=subprocess.PIPE)
600 p = subprocess.Popen([sys.executable, "-c",
611 p = subprocess.Popen([sys.executable, "-c",
624 p = subprocess.Popen([sys.executable, "-c",
625 'import sys, subprocess;'
626 'rc = subprocess.call([sys.executable, "-c",'
629 ' stderr=subprocess.STDOUT);'
631 stdout=subprocess.PIPE,
632 stderr=subprocess.PIPE)
641 p = subprocess.Popen([sys.executable, "-c",
646 stdout=subprocess.PIPE,
647 stderr=subprocess.STDOUT)
655 p = subprocess.Popen([sys.executable, "-c",
669 # test_stdout_none (see above). The parent subprocess calls the child
670 # subprocess passing stdout=1, and this test uses stdout=PIPE in
672 code = ('import sys, subprocess; '
673 'rc = subprocess.call([sys.executable, "-c", '
677 p = subprocess.Popen([sys.executable, "-c", code],
678 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
686 p = subprocess.Popen([sys.executable, "-c",
689 stdout=subprocess.DEVNULL)
694 p = subprocess.Popen([sys.executable, "-c",
698 stderr=subprocess.DEVNULL)
703 p = subprocess.Popen([sys.executable, "-c",
706 stdin=subprocess.DEVNULL)
724 p = subprocess.Popen(
728 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
729 stderr=subprocess.PIPE, pipesize=pipesize)
749 p = subprocess.Popen(
753 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
754 stderr=subprocess.PIPE, pipesize=-1)
778 with subprocess.Popen([sys.executable, "-c",
781 stdout=subprocess.PIPE,
807 with subprocess.Popen([sys.executable, "-c",
809 stdout=subprocess.PIPE, env={}) as p:
821 subprocess.Popen([cmd, "-c", "pass"])
825 subprocess.Popen([sys.executable, "-c", "pass#\0"])
832 subprocess.Popen(ZERO_RETURN_CMD, env=newenv)
838 subprocess.Popen(ZERO_RETURN_CMD, env=newenv)
844 subprocess.Popen(ZERO_RETURN_CMD, env=newenv)
849 with subprocess.Popen([sys.executable, "-c",
852 stdout=subprocess.PIPE,
858 p = subprocess.Popen([sys.executable, "-c",
861 stdin=subprocess.PIPE)
866 p = subprocess.Popen([sys.executable, "-c",
868 stdout=subprocess.PIPE)
874 p = subprocess.Popen([sys.executable, "-c",
876 stderr=subprocess.PIPE)
882 p = subprocess.Popen([sys.executable, "-c",
886 stdin=subprocess.PIPE,
887 stdout=subprocess.PIPE,
888 stderr=subprocess.PIPE)
897 p = subprocess.Popen([sys.executable, "-c",
904 stdin=subprocess.PIPE,
905 stdout=subprocess.PIPE,
906 stderr=subprocess.PIPE)
907 self.assertRaises(subprocess.TimeoutExpired, p.communicate, "banana",
917 p = subprocess.Popen([sys.executable, "-c",
926 stdout=subprocess.PIPE)
927 self.assertRaises(subprocess.TimeoutExpired, p.communicate, timeout=0.4)
938 options['stdin'] = subprocess.PIPE
940 options['stdout'] = subprocess.PIPE
942 options['stderr'] = subprocess.PIPE
945 p = subprocess.Popen(ZERO_RETURN_CMD, **options)
956 p = subprocess.Popen([sys.executable, "-c",
969 p = subprocess.Popen([sys.executable, "-c",
975 stdin=subprocess.PIPE,
976 stdout=subprocess.PIPE,
977 stderr=subprocess.PIPE)
987 p = subprocess.Popen([sys.executable, "-c",
990 stdin=subprocess.PIPE,
991 stdout=subprocess.PIPE,
992 stderr=subprocess.PIPE)
1023 p = subprocess.Popen(args, **{'stdin': subprocess.PIPE,
1024 'stdout': subprocess.PIPE,
1042 p = subprocess.Popen([sys.executable, "-c",
1056 stderr=subprocess.PIPE,
1057 stdout=subprocess.PIPE,
1067 p = subprocess.Popen([sys.executable, "-c",
1074 stdin=subprocess.PIPE,
1084 p = subprocess.Popen(ZERO_RETURN_CMD,
1085 stdin=subprocess.PIPE,
1086 stdout=subprocess.PIPE,
1093 p = subprocess.Popen([sys.executable, "-c",
1106 stdin=subprocess.PIPE,
1107 stderr=subprocess.PIPE,
1108 stdout=subprocess.PIPE,
1116 # to stderr at exit of subprocess.
1134 popen = subprocess.Popen(args,
1135 stdin=subprocess.PIPE,
1136 stdout=subprocess.PIPE,
1154 popen = subprocess.Popen(args,
1155 stdin=subprocess.PIPE,
1156 stdout=subprocess.PIPE,
1182 # Close a couple of them (should be enough for a subprocess)
1188 p = subprocess.Popen([sys.executable, "-c",
1191 stdin=subprocess.PIPE,
1192 stdout=subprocess.PIPE,
1193 stderr=subprocess.PIPE)
1202 self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']),
1204 self.assertEqual(subprocess.list2cmdline(['ab"c', '\\', 'd']),
1206 self.assertEqual(subprocess.list2cmdline(['ab"c', ' \\', 'd']),
1208 self.assertEqual(subprocess.list2cmdline(['a\\\\\\b', 'de fg', 'h']),
1210 self.assertEqual(subprocess.list2cmdline(['a\\"b', 'c', 'd']),
1212 self.assertEqual(subprocess.list2cmdline(['a\\\\b c', 'd', 'e']),
1214 self.assertEqual(subprocess.list2cmdline(['a\\\\b\\ c', 'd', 'e']),
1216 self.assertEqual(subprocess.list2cmdline(['ab', '']),
1220 p = subprocess.Popen([sys.executable, "-c",
1222 stdin=subprocess.PIPE)
1231 p = subprocess.Popen(ZERO_RETURN_CMD)
1237 p = subprocess.Popen([sys.executable,
1239 with self.assertRaises(subprocess.TimeoutExpired) as c:
1248 subprocess.Popen(ZERO_RETURN_CMD, "orange")
1252 p = subprocess.Popen(ZERO_RETURN_CMD, None)
1255 p = subprocess.Popen(ZERO_RETURN_CMD, bufsize=None)
1259 # subprocess may deadlock with bufsize=1, see issue #21332
1260 with subprocess.Popen([sys.executable, "-c", "import sys;"
1263 stdin=subprocess.PIPE,
1264 stdout=subprocess.PIPE,
1265 stderr=subprocess.DEVNULL,
1301 subprocess.Popen(NONEXISTING_CMD,
1302 stdout=subprocess.PIPE,
1303 stderr=subprocess.PIPE)
1310 # Run the test in a subprocess to control how the CRT reports errors
1320 import subprocess
1331 subprocess.Popen(cmd,
1332 stdout=subprocess.PIPE,
1333 stderr=subprocess.PIPE)
1338 proc = subprocess.Popen(cmd,
1339 stderr=subprocess.PIPE,
1357 subprocess.Popen(NONEXISTING_CMD,
1358 stdin=subprocess.PIPE,
1359 stdout=subprocess.PIPE,
1360 stderr=subprocess.PIPE)
1377 proc = subprocess.Popen([sys.executable, '-c',
1431 'import subprocess, sys',
1432 'retcode = subprocess.call('
1435 output = subprocess.check_output([sys.executable, '-c', code])
1445 subprocess.Popen (["*"], stdin=ifhandle, stdout=ofhandle,
1460 p = subprocess.Popen(ZERO_RETURN_CMD,
1461 stdin=subprocess.PIPE,
1462 stdout=subprocess.PIPE,
1463 stderr=subprocess.PIPE)
1482 with unittest.mock.patch.object(subprocess.Popen, '_execute_child'):
1484 p = subprocess.Popen(cmd, shell=shell)
1490 p = subprocess.Popen(ZERO_RETURN_CMD,
1491 stdin=subprocess.PIPE)
1513 kw = {stream: subprocess.PIPE}
1514 with subprocess.Popen(args, **kw) as process:
1529 ZERO_RETURN_CMD, stdin=subprocess.PIPE,
1530 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
1542 subprocess.call(['/opt/nonexistent_binary', 'with', 'some', 'args'])
1548 subprocess.Popen(['exit', '0'], cwd='/some/nonexistent/directory')
1552 self.assertIsInstance(subprocess.Popen[bytes], types.GenericAlias)
1553 self.assertIsInstance(subprocess.CompletedProcess[str], types.GenericAlias)
1557 @mock.patch("subprocess._fork_exec")
1559 self.assertTrue(subprocess._USE_VFORK) # The default value regardless.
1562 subprocess.run([sys.executable, "-c", "pass"])
1565 with mock.patch.object(subprocess, '_USE_VFORK', False):
1567 subprocess.run([sys.executable, "-c", "pass"])
1573 """Run Python code in a subprocess using subprocess.run"""
1575 return subprocess.run(argv, **kwargs)
1581 with self.assertRaises(subprocess.CalledProcessError):
1585 with self.assertRaises(subprocess.CalledProcessError) as c:
1591 cp = subprocess.run(ZERO_RETURN_CMD, check=True)
1597 # killed, this call will deadlock since subprocess.run waits for the
1599 with self.assertRaises(subprocess.TimeoutExpired):
1604 cp = self.run_python("print('BDFL')", stdout=subprocess.PIPE)
1609 stderr=subprocess.PIPE)
1620 stdin=tf, stdout=subprocess.PIPE)
1627 input=b'pear', stdout=subprocess.PIPE)
1644 with self.assertRaises(subprocess.TimeoutExpired) as c:
1652 timeout=3, stdout=subprocess.PIPE)
1674 res = subprocess.run(path, stdout=subprocess.DEVNULL)
1677 subprocess.run(path, stdout=subprocess.DEVNULL, shell=True)
1683 res = subprocess.run(args)
1690 res = subprocess.run(args)
1734 subprocess.run('sleep 3', shell=True, timeout=0.1,
1736 except subprocess.TimeoutExpired as exc:
1747 from subprocess import *
1751 cp = subprocess.run([sys.executable, "-Xwarn_default_encoding", "-c", code],
1795 p = subprocess.Popen([sys.executable, "-c", ""],
1810 p = subprocess.Popen([sys.executable, "-c", ""],
1825 p = subprocess.Popen([self._nonexistent_dir, "-c", ""])
1842 class PopenNoDestructor(subprocess.Popen):
1846 @mock.patch("subprocess._fork_exec")
1858 with mock.patch("subprocess.os.waitpid",
1863 @mock.patch("subprocess._fork_exec")
1878 with mock.patch("subprocess.os.waitpid",
1880 with self.assertRaises(subprocess.SubprocessError) as e:
1889 default_proc_status = subprocess.check_output(
1898 restored_proc_status = subprocess.check_output(
1914 output = subprocess.check_output(
1932 output = subprocess.check_output(
1966 output = subprocess.check_output(
1985 subprocess.check_call(ZERO_RETURN_CMD, user=-1)
1988 subprocess.check_call(ZERO_RETURN_CMD,
1993 subprocess.check_call(ZERO_RETURN_CMD, user=name_uid)
1998 subprocess.check_call(ZERO_RETURN_CMD, user=65535)
2014 output = subprocess.check_output(
2032 subprocess.check_call(ZERO_RETURN_CMD, group=-1)
2035 subprocess.check_call(ZERO_RETURN_CMD,
2040 subprocess.check_call(ZERO_RETURN_CMD, group=name_group)
2045 subprocess.check_call(ZERO_RETURN_CMD, group=65535)
2058 output = subprocess.check_output(
2084 subprocess.check_call(ZERO_RETURN_CMD, extra_groups=[-1])
2087 subprocess.check_call(ZERO_RETURN_CMD,
2093 subprocess.check_call(ZERO_RETURN_CMD,
2099 subprocess.check_call(ZERO_RETURN_CMD, extra_groups=[])
2110 subprocess.check_call(
2126 p = subprocess.Popen([sys.executable, "-c",
2132 err = subprocess.CalledProcessError(-int(signal.SIGABRT), "fake cmd")
2143 err = subprocess.CalledProcessError(-9876543, "fake cmd")
2148 err = subprocess.CalledProcessError(2, "fake cmd")
2155 p = subprocess.Popen([sys.executable, "-c",
2158 stdout=subprocess.PIPE,
2167 p = subprocess.Popen([sys.executable, "-c", ""],
2169 except subprocess.SubprocessError as e:
2171 subprocess._fork_exec,
2179 class _TestExecuteChildPopen(subprocess.Popen):
2183 subprocess.Popen.__init__(self, *args, **kwargs)
2187 subprocess.Popen._execute_child(self, *args, **kwargs)
2209 raise subprocess.SubprocessError(
2212 with self.assertRaises(subprocess.SubprocessError):
2215 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
2216 stderr=subprocess.PIPE, preexec_fn=raise_it)
2225 subprocess.call([sys.executable, '-c', ''],
2232 subprocess.call([sys.executable, '-c', ''],
2253 subprocess.call([sys.executable, '-c', ''],
2270 p = subprocess.Popen(fname)
2277 self.assertRaises(ValueError, subprocess.call,
2281 self.assertRaises(ValueError, subprocess.call,
2290 p = subprocess.Popen(["echo $FRUIT"], shell=1,
2291 stdout=subprocess.PIPE,
2300 p = subprocess.Popen("echo $FRUIT", shell=1,
2301 stdout=subprocess.PIPE,
2315 rc = subprocess.call(fname)
2334 p = subprocess.Popen("echo $0", executable=sh, shell=True,
2335 stdout=subprocess.PIPE)
2346 p = subprocess.Popen([sys.executable, "-c", """if 1:
2353 stdin=subprocess.PIPE,
2354 stdout=subprocess.PIPE,
2355 stderr=subprocess.PIPE)
2369 p = subprocess.Popen([sys.executable, "-c", """if 1:
2375 stdin=subprocess.PIPE,
2376 stdout=subprocess.PIPE,
2377 stderr=subprocess.PIPE)
2431 # Issue #9905: test that subprocess pipes still work properly with
2442 out, err = subprocess.Popen([sys.executable, "-c",
2448 stdout=subprocess.PIPE,
2449 stderr=subprocess.PIPE).communicate()
2474 # Issue #10806: test that subprocess pipes still work properly with
2489 subprocess.Popen([
2520 # now use those files in the "wrong" order, so that subprocess
2522 p = subprocess.Popen([sys.executable, "-c",
2564 # now use those files in the given order, so that subprocess
2566 p = subprocess.Popen([sys.executable, "-c",
2625 rc = subprocess.call([sys.executable, '-c', code, str(skipped_fd)],
2642 # Check that subprocess can remap std fds correctly even
2654 subprocess.call(
2659 self.assertIsNone(subprocess._fork_exec)
2661 except subprocess.SubprocessError as err:
2663 self.assertIsNotNone(subprocess._fork_exec)
2666 self.fail("Expected ValueError or subprocess.SubprocessError")
2680 stdout = subprocess.check_output(
2691 stdout = subprocess.check_output(
2704 exitcode = subprocess.call([abs_program]+args)
2709 exitcode = subprocess.call(cmd, shell=True)
2715 exitcode = subprocess.call([program]+args, env=env)
2721 exitcode = subprocess.call([program]+args, env=envb)
2728 p1 = subprocess.Popen([sys.executable, sleeper],
2729 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
2730 stderr=subprocess.PIPE, close_fds=False)
2734 p2 = subprocess.Popen([sys.executable, fd_status],
2735 stdout=subprocess.PIPE, close_fds=False)
2754 p1 = subprocess.Popen([sys.executable, qcat],
2755 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
2758 p2 = subprocess.Popen([sys.executable, qgrep, subdata],
2759 stdin=p1.stdout, stdout=subprocess.PIPE,
2805 p = subprocess.Popen([sys.executable, fd_status],
2806 stdout=subprocess.PIPE, close_fds=False)
2813 p = subprocess.Popen([sys.executable, fd_status],
2814 stdout=subprocess.PIPE, close_fds=True)
2822 # Keep some of the fd's we opened open in the subprocess.
2825 p = subprocess.Popen([sys.executable, fd_status],
2826 stdout=subprocess.PIPE, close_fds=True,
2852 # subprocess with close_fds=True so we can find out if
2854 p = subprocess.Popen([sys.executable, '-c', textwrap.dedent(
2856 import os, resource, subprocess, sys, textwrap
2886 # inherits open fds above that limit. It then uses subprocess
2891 subprocess.Popen(
2894 import subprocess, sys
2895 subprocess.Popen([sys.executable, %r] +
2902 ''' % fd_status)], stdout=subprocess.PIPE)
2934 p = subprocess.Popen([sys.executable, fd_status],
2935 stdout=subprocess.PIPE, close_fds=True,
2948 self.assertFalse(subprocess.call(
2965 p = subprocess.Popen(args,
2966 stdout=subprocess.PIPE, close_fds=True,
2997 with subprocess.Popen([sys.executable, fd_status],
3011 p = subprocess.Popen(ZERO_RETURN_CMD,
3017 p = subprocess.Popen(ZERO_RETURN_CMD,
3023 p = subprocess.Popen(ZERO_RETURN_CMD,
3031 p = subprocess.Popen([sys.executable, sigchild_ignore],
3032 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
3042 p = subprocess.Popen([sys.executable, "-c",
3045 stdout=subprocess.PIPE,
3057 # process exited, it wouldn't be added to subprocess._active, and would
3060 p = subprocess.Popen([sys.executable, "-c",
3063 stdout=subprocess.PIPE,
3064 stderr=subprocess.PIPE)
3073 # subprocess._active is not used on Windows and is set to None.
3074 self.assertIsNone(subprocess._active)
3077 self.assertIn(ident, [id(o) for o in subprocess._active])
3082 # be removed from subprocess._active, which triggered a FD and memory
3085 p = subprocess.Popen([sys.executable, "-c",
3088 stdout=subprocess.PIPE,
3089 stderr=subprocess.PIPE)
3100 # subprocess._active is not used on Windows and is set to None.
3101 self.assertIsNone(subprocess._active)
3104 self.assertIn(ident, [id(o) for o in subprocess._active])
3110 with subprocess.Popen(NONEXISTING_CMD,
3111 stdout=subprocess.PIPE,
3112 stderr=subprocess.PIPE) as proc:
3117 # subprocess._active is not used on Windows and is set to None.
3118 self.assertIsNone(subprocess._active)
3120 self.assertNotIn(ident, [id(o) for o in subprocess._active])
3130 p = subprocess.Popen([sys.executable, fd_status],
3131 stdout=subprocess.PIPE, close_fds=True,
3224 proc = subprocess.Popen(ZERO_RETURN_CMD)
3233 proc = subprocess.Popen(ZERO_RETURN_CMD)
3243 proc = subprocess.Popen([sys.executable, '-h'],
3244 stdin=subprocess.PIPE,
3245 stdout=subprocess.PIPE)
3258 proc = subprocess.Popen([sys.executable, '-h'],
3259 stdin=subprocess.PIPE,
3260 stdout=subprocess.PIPE)
3273 proc = subprocess.Popen(args)
3279 with mock.patch('subprocess.os.waitpid', return_value=(proc.pid, status)):
3287 proc = subprocess.Popen(ZERO_RETURN_CMD)
3309 p = subprocess.Popen([sys.executable, '-c', 'exit(1)'])
3321 proc = subprocess.Popen([sys.executable, '-c',
3323 stdout=subprocess.PIPE)
3328 except subprocess.TimeoutExpired:
3341 startupinfo = subprocess.STARTUPINFO()
3347 subprocess.call(ZERO_RETURN_CMD,
3356 startupinfo = subprocess.STARTUPINFO(
3363 subprocess.call(ZERO_RETURN_CMD,
3368 startupinfo = subprocess.STARTUPINFO()
3369 startupinfo.dwFlags = subprocess.STARTF_USESHOWWINDOW
3370 startupinfo.wShowWindow = subprocess.SW_HIDE
3377 proc = subprocess.Popen(cmd,
3379 stderr=subprocess.STDOUT,
3386 subprocess.STARTF_USESHOWWINDOW)
3390 self.assertEqual(startupinfo.wShowWindow, subprocess.SW_HIDE)
3397 subprocess.call(sys.executable +
3403 self.assertRaises(ValueError, subprocess.call,
3415 subprocess.Popen(ZERO_RETURN_CMD, env=BadEnv())
3419 rc = subprocess.call([sys.executable, "-c",
3436 p = subprocess.Popen([sys.executable, "-c",
3438 stdout=subprocess.PIPE, close_fds=False)
3443 p = subprocess.Popen([sys.executable, "-c",
3445 stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
3452 startupinfo = subprocess.STARTUPINFO()
3454 p = subprocess.Popen([sys.executable, "-c",
3456 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
3465 startupinfo = subprocess.STARTUPINFO()
3467 p = subprocess.Popen([sys.executable, "-c",
3469 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
3475 startupinfo = subprocess.STARTUPINFO()
3477 subprocess.call(ZERO_RETURN_CMD,
3481 startupinfo = subprocess.STARTUPINFO()
3483 subprocess.call(ZERO_RETURN_CMD,
3490 p = subprocess.Popen(["set"], shell=1,
3491 stdout=subprocess.PIPE,
3500 p = subprocess.Popen("set", shell=1,
3501 stdout=subprocess.PIPE,
3511 p = subprocess.Popen("set", shell=1,
3512 stdout=subprocess.PIPE,
3520 rc = subprocess.call(sys.executable +
3526 p = subprocess.Popen([sys.executable, "-c", """if 1:
3532 stdin=subprocess.PIPE,
3533 stdout=subprocess.PIPE,
3534 stderr=subprocess.PIPE)
3546 p = subprocess.Popen([sys.executable, "-c", """if 1:
3552 stdin=subprocess.PIPE,
3553 stdout=subprocess.PIPE,
3554 stderr=subprocess.PIPE)
3588 class RecordingPopen(subprocess.Popen):
3596 @mock.patch.object(subprocess.Popen, "_communicate")
3603 happening during a blocking subprocess execution which we want to clean
3609 with mock.patch.object(subprocess.Popen, "_wait") as mock__wait:
3613 with mock.patch.object(subprocess, "Popen",
3619 stdout=subprocess.DEVNULL, **kwargs)
3641 self._test_keyboardinterrupt_no_kill(subprocess.call, timeout=6.282)
3644 self._test_keyboardinterrupt_no_kill(subprocess.run, timeout=6.282)
3648 with subprocess.Popen(*args, **kwargs) as unused_process:
3653 self.assertEqual(subprocess.getoutput('echo xyzzy'), 'xyzzy')
3654 self.assertEqual(subprocess.getstatusoutput('echo xyzzy'),
3664 status, output = subprocess.getstatusoutput(
3674 exported = set(subprocess.__all__)
3677 for name, value in subprocess.__dict__.items():
3690 self.orig_selector = subprocess._PopenSelector
3691 subprocess._PopenSelector = selectors.SelectSelector
3695 subprocess._PopenSelector = self.orig_selector
3716 kwargs['stdout'] = subprocess.PIPE
3717 p = subprocess.Popen(*args, **kwargs)
3746 with subprocess.Popen([sys.executable, "-c",
3750 stdout=subprocess.PIPE,
3751 stderr=subprocess.PIPE) as proc:
3759 with subprocess.Popen([sys.executable, "-c",
3766 with subprocess.Popen([sys.executable, "-c",
3769 stdin=subprocess.PIPE) as proc:
3775 with subprocess.Popen(NONEXISTING_CMD,
3776 stdout=subprocess.PIPE,
3777 stderr=subprocess.PIPE) as proc:
3782 proc = subprocess.Popen(ZERO_RETURN_CMD,
3783 stdin=subprocess.PIPE,