Skip to content

Commit 99ab8ae

Browse files
antosikvbluetech
andauthored
Clarify docs for pytest.main default behavior (#11187)
Add explicit mentions of the default behavior to both API reference and how-to section about ways to invoke pytest. Co-authored-by: Ran Benita <[email protected]>
1 parent 782cacf commit 99ab8ae

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

doc/en/how-to/usage.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ You can invoke ``pytest`` from Python code directly:
173173
174174
this acts as if you would call "pytest" from the command line.
175175
It will not raise :class:`SystemExit` but return the :ref:`exit code <exit-codes>` instead.
176-
You can pass in options and arguments:
176+
If you don't pass it any arguments, ``main`` reads the arguments from the command line arguments of the process (:data:`sys.argv`), which may be undesirable.
177+
You can pass in options and arguments explicitly:
177178

178179
.. code-block:: python
179180

src/_pytest/config/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ def main(
137137
) -> Union[int, ExitCode]:
138138
"""Perform an in-process test run.
139139
140-
:param args: List of command line arguments.
140+
:param args:
141+
List of command line arguments. If `None` or not given, defaults to reading
142+
arguments directly from the process command line (:data:`sys.argv`).
141143
:param plugins: List of plugin objects to be auto-registered during initialization.
142144
143145
:returns: An exit code.

0 commit comments

Comments
 (0)