MCPcopy
hub / github.com/pytest-dev/pytest / sysexec

Method sysexec

src/_pytest/_py/path.py:1159–1190  ·  view source on GitHub ↗

Return stdout text from executing a system child process, where the 'self' path points to executable. The process is directly invoked and not through a system shell.

(self, *argv: os.PathLike[str], **popen_opts: Any)

Source from the content-addressed store, hash-verified

1157 return mod
1158
1159 def sysexec(self, *argv: os.PathLike[str], **popen_opts: Any) -> str:
1160 """Return stdout text from executing a system child process,
1161 where the 'self' path points to executable.
1162 The process is directly invoked and not through a system shell.
1163 """
1164 from subprocess import PIPE
1165 from subprocess import Popen
1166
1167 popen_opts.pop("stdout", None)
1168 popen_opts.pop("stderr", None)
1169 proc = Popen(
1170 [str(self)] + [str(arg) for arg in argv],
1171 **popen_opts,
1172 stdout=PIPE,
1173 stderr=PIPE,
1174 )
1175 stdout: str | bytes
1176 stdout, stderr = proc.communicate()
1177 ret = proc.wait()
1178 if isinstance(stdout, bytes):
1179 stdout = stdout.decode(sys.getdefaultencoding())
1180 if ret != 0:
1181 if isinstance(stderr, bytes):
1182 stderr = stderr.decode(sys.getdefaultencoding())
1183 raise RuntimeError(
1184 ret,
1185 ret,
1186 str(self),
1187 stdout,
1188 stderr,
1189 )
1190 return stdout
1191
1192 @classmethod
1193 def sysfind(cls, name, checker=None, paths=None):

Callers 2

test_sysexecMethod · 0.80
test_sysexec_failingMethod · 0.80

Calls 1

popMethod · 0.80

Tested by 2

test_sysexecMethod · 0.64
test_sysexec_failingMethod · 0.64