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
Prev Previous commit
Slightly reword the docs about default main behavior
Explicitly mention reading arguments from `sys.argv` to avoid any confusion.

Co-authored-by: Ran Benita <[email protected]>
  • Loading branch information
antosikv and bluetech authored Jul 9, 2023
commit f7182ce78ab1efb59e004b15801de10a11f7d1a0
3 changes: 1 addition & 2 deletions doc/en/how-to/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ 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.
Be careful though, by default (when ``None`` is passed) ``main`` will read arguments
from the command line, which may not be desirable.
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.
You can pass in options and arguments explicitly:

.. code-block:: python
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def main(

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

:returns: An exit code.
Expand Down