diff --git a/doc/en/how-to/usage.rst b/doc/en/how-to/usage.rst index 8e2dd8673..c0d122e6f 100644 --- a/doc/en/how-to/usage.rst +++ b/doc/en/how-to/usage.rst @@ -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 ` 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 diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 47651ad9f..cd404ed25 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -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.