Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hookspec: minor doc tweaks #11822

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Changes from all commits
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
38 changes: 20 additions & 18 deletions src/_pytest/hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def pytest_addhooks(pluginmanager: "PytestPluginManager") -> None:
"""Called at plugin registration time to allow adding new hooks via a call to
:func:`pluginmanager.add_hookspecs(module_or_class, prefix) <pytest.PytestPluginManager.add_hookspecs>`.

:param pytest.PytestPluginManager pluginmanager: The pytest plugin manager.
:param pluginmanager: The pytest plugin manager.

.. note::
This hook is incompatible with hook wrappers.
Expand All @@ -68,7 +68,7 @@ def pytest_plugin_registered(
"""A new pytest plugin got registered.

:param plugin: The plugin module or instance.
:param pytest.PytestPluginManager manager: pytest plugin manager.
:param manager: pytest plugin manager.

.. note::
This hook is incompatible with hook wrappers.
Expand All @@ -86,13 +86,13 @@ def pytest_addoption(parser: "Parser", pluginmanager: "PytestPluginManager") ->
files situated at the tests root directory due to how pytest
:ref:`discovers plugins during startup <pluginorder>`.

:param pytest.Parser parser:
:param parser:
To add command line options, call
:py:func:`parser.addoption(...) <pytest.Parser.addoption>`.
To add ini-file values call :py:func:`parser.addini(...)
<pytest.Parser.addini>`.

:param pytest.PytestPluginManager pluginmanager:
:param pluginmanager:
The pytest plugin manager, which can be used to install :py:func:`~pytest.hookspec`'s
or :py:func:`~pytest.hookimpl`'s and allow one plugin to call another plugin's hooks
to change how command line options are added.
Expand Down Expand Up @@ -127,7 +127,7 @@ def pytest_configure(config: "Config") -> None:
.. note::
This hook is incompatible with hook wrappers.

:param pytest.Config config: The pytest config object.
:param config: The pytest config object.
"""


Expand Down Expand Up @@ -156,18 +156,6 @@ def pytest_cmdline_parse(
"""


@hookspec(firstresult=True)
def pytest_cmdline_main(config: "Config") -> Optional[Union["ExitCode", int]]:
"""Called for performing the main command line action. The default
implementation will invoke the configure hooks and runtest_mainloop.

Stops at first non-None result, see :ref:`firstresult`.

:param config: The pytest config object.
:returns: The exit code.
"""


def pytest_load_initial_conftests(
early_config: "Config", parser: "Parser", args: List[str]
) -> None:
Expand All @@ -183,6 +171,20 @@ def pytest_load_initial_conftests(
"""


@hookspec(firstresult=True)
def pytest_cmdline_main(config: "Config") -> Optional[Union["ExitCode", int]]:
"""Called for performing the main command line action.

The default implementation will invoke the configure hooks and
:hook:`pytest_runtestloop`.

Stops at first non-None result, see :ref:`firstresult`.

:param config: The pytest config object.
:returns: The exit code.
"""


# -------------------------------------------------------------------------
# collection hooks
# -------------------------------------------------------------------------
Expand Down Expand Up @@ -435,7 +437,7 @@ def pytest_make_parametrize_id(

:param config: The pytest config object.
:param val: The parametrized value.
:param str argname: The automatic parameter name produced by pytest.
:param argname: The automatic parameter name produced by pytest.
"""


Expand Down