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

Method popen

src/_pytest/pytester.py:1349–1385  ·  view source on GitHub ↗

Invoke :py:class:`subprocess.Popen`. Calls :py:class:`subprocess.Popen` making sure the current working directory is in ``PYTHONPATH``. You probably want to use :py:meth:`run` instead.

(
        self,
        cmdargs: Sequence[str | os.PathLike[str]],
        stdout: int | TextIO = subprocess.PIPE,
        stderr: int | TextIO = subprocess.PIPE,
        stdin: NotSetType | bytes | IO[Any] | int = CLOSE_STDIN,
        **kw,
    )

Source from the content-addressed store, hash-verified

1347 return None
1348
1349 def popen(
1350 self,
1351 cmdargs: Sequence[str | os.PathLike[str]],
1352 stdout: int | TextIO = subprocess.PIPE,
1353 stderr: int | TextIO = subprocess.PIPE,
1354 stdin: NotSetType | bytes | IO[Any] | int = CLOSE_STDIN,
1355 **kw,
1356 ):
1357 """Invoke :py:class:`subprocess.Popen`.
1358
1359 Calls :py:class:`subprocess.Popen` making sure the current working
1360 directory is in ``PYTHONPATH``.
1361
1362 You probably want to use :py:meth:`run` instead.
1363 """
1364 env = os.environ.copy()
1365 env["PYTHONPATH"] = os.pathsep.join(
1366 filter(None, [os.getcwd(), env.get("PYTHONPATH", "")])
1367 )
1368 kw["env"] = env
1369
1370 if stdin is self.CLOSE_STDIN:
1371 kw["stdin"] = subprocess.PIPE
1372 elif isinstance(stdin, bytes):
1373 kw["stdin"] = subprocess.PIPE
1374 else:
1375 kw["stdin"] = stdin
1376
1377 popen = subprocess.Popen(cmdargs, stdout=stdout, stderr=stderr, **kw)
1378 if stdin is self.CLOSE_STDIN:
1379 assert popen.stdin is not None
1380 popen.stdin.close()
1381 elif isinstance(stdin, bytes):
1382 assert popen.stdin is not None
1383 popen.stdin.write(stdin)
1384
1385 return popen
1386
1387 def run(
1388 self,

Callers 4

runMethod · 0.95
test_popen_stdin_pipeFunction · 0.45
test_popen_stdin_bytesFunction · 0.45

Calls 5

copyMethod · 0.80
joinMethod · 0.80
getMethod · 0.45
closeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected