Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Clarify docs for pytest.main default behavior
Add explicit mentions of the default behavior to both API reference and
how-to section about ways to invoke pytest.
  • Loading branch information
antosikv committed Jul 9, 2023
commit c27ba33eb7350d3626df689210ab6994cc8c705f
4 changes: 3 additions & 1 deletion doc/en/how-to/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ You can invoke ``pytest`` from Python code directly:

this acts as if you would call "pytest" from the command line.
It will not raise :class:`SystemExit` but return the :ref:`exit code <exit-codes>` instead.
You can pass in options and arguments:
Be careful though, by default (when ``None`` is passed) ``main`` will read arguments
from the command line, which may not be desirable.
You can pass in options and arguments explicitly:

.. code-block:: python

Expand Down
4 changes: 3 additions & 1 deletion src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ def main(
) -> Union[int, ExitCode]:
"""Perform an in-process test run.

:param args: List of command line arguments.
:param args:
List of command line arguments. If `None` or not given, defaults to reading
arguments directly from the command line.
:param plugins: List of plugin objects to be auto-registered during initialization.

:returns: An exit code.
Expand Down