Skip to content

Commit 07f0eb2

Browse files
xuhdevnicoddemus
andauthored
Doc: Clarify pytester.run (#8294)
Co-authored-by: Bruno Oliveira <[email protected]>
1 parent 63ea727 commit 07f0eb2

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/_pytest/pytester.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,16 +1296,16 @@ def collect_by_name(
12961296

12971297
def popen(
12981298
self,
1299-
cmdargs,
1299+
cmdargs: Sequence[Union[str, "os.PathLike[str]"]],
13001300
stdout: Union[int, TextIO] = subprocess.PIPE,
13011301
stderr: Union[int, TextIO] = subprocess.PIPE,
13021302
stdin=CLOSE_STDIN,
13031303
**kw,
13041304
):
1305-
"""Invoke subprocess.Popen.
1305+
"""Invoke :py:class:`subprocess.Popen`.
13061306
1307-
Calls subprocess.Popen making sure the current working directory is
1308-
in the PYTHONPATH.
1307+
Calls :py:class:`subprocess.Popen` making sure the current working
1308+
directory is in the ``PYTHONPATH``.
13091309
13101310
You probably want to use :py:meth:`run` instead.
13111311
"""
@@ -1340,21 +1340,30 @@ def run(
13401340
) -> RunResult:
13411341
"""Run a command with arguments.
13421342
1343-
Run a process using subprocess.Popen saving the stdout and stderr.
1343+
Run a process using :py:class:`subprocess.Popen` saving the stdout and
1344+
stderr.
13441345
13451346
:param cmdargs:
1346-
The sequence of arguments to pass to `subprocess.Popen()`, with path-like objects
1347-
being converted to ``str`` automatically.
1347+
The sequence of arguments to pass to :py:class:`subprocess.Popen`,
1348+
with path-like objects being converted to :py:class:`str`
1349+
automatically.
13481350
:param timeout:
13491351
The period in seconds after which to timeout and raise
13501352
:py:class:`Pytester.TimeoutExpired`.
13511353
:param stdin:
1352-
Optional standard input. Bytes are being send, closing
1353-
the pipe, otherwise it is passed through to ``popen``.
1354-
Defaults to ``CLOSE_STDIN``, which translates to using a pipe
1355-
(``subprocess.PIPE``) that gets closed.
1354+
Optional standard input.
13561355
1357-
:rtype: RunResult
1356+
- If it is :py:attr:`CLOSE_STDIN` (Default), then this method calls
1357+
:py:class:`subprocess.Popen` with ``stdin=subprocess.PIPE``, and
1358+
the standard input is closed immediately after the new command is
1359+
started.
1360+
1361+
- If it is of type :py:class:`bytes`, these bytes are sent to the
1362+
standard input of the command.
1363+
1364+
- Otherwise, it is passed through to :py:class:`subprocess.Popen`.
1365+
For further information in this case, consult the document of the
1366+
``stdin`` parameter in :py:class:`subprocess.Popen`.
13581367
"""
13591368
__tracebackhide__ = True
13601369

0 commit comments

Comments
 (0)