Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changelog/13625.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added missing docstrings to ``pytest_addoption()``, ``pytest_configure()``, and ``cacheshow()`` functions in ``cacheprovider.py``.
21 changes: 21 additions & 0 deletions src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,10 @@ def pytest_sessionfinish(self) -> None:


def pytest_addoption(parser: Parser) -> None:
"""Add command-line options for cache functionality.

:param parser: Parser object to add command-line options to.
"""
group = parser.getgroup("general")
group.addoption(
"--lf",
Expand Down Expand Up @@ -546,6 +550,13 @@ def pytest_cmdline_main(config: Config) -> int | ExitCode | None:

@hookimpl(tryfirst=True)
def pytest_configure(config: Config) -> None:
"""Configure cache system and register related plugins.

Creates the Cache instance and registers the last-failed (LFPlugin)
and new-first (NFPlugin) plugins with the plugin manager.

:param config: pytest configuration object.
"""
config.cache = Cache.for_config(config, _ispytest=True)
config.pluginmanager.register(LFPlugin(config), "lfplugin")
config.pluginmanager.register(NFPlugin(config), "nfplugin")
Expand Down Expand Up @@ -584,6 +595,16 @@ def pytest_report_header(config: Config) -> str | None:


def cacheshow(config: Config, session: Session) -> int:
"""Display cache contents when --cache-show is used.

Shows cached values and directories matching the specified glob pattern
(default: '*'). Displays cache location, cached test results, and
any cached directories created by plugins.

:param config: pytest configuration object.
:param session: pytest session object.
:returns: Exit code (0 for success).
"""
from pprint import pformat

assert config.cache is not None
Expand Down
Loading