From 2f8a509844a57417287d580e51b26ece9db887c2 Mon Sep 17 00:00:00 2001 From: Ali Nazzal Date: Thu, 21 Aug 2025 12:41:11 +0300 Subject: [PATCH 1/3] docs(cacheprovider): add docstrings; add changelog fragment (refs #13625) --- changelog/13625.doc.rst | 1 + src/_pytest/cacheprovider.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 changelog/13625.doc.rst diff --git a/changelog/13625.doc.rst b/changelog/13625.doc.rst new file mode 100644 index 00000000000..961850200ea --- /dev/null +++ b/changelog/13625.doc.rst @@ -0,0 +1 @@ +Added missing docstrings to ``pytest_addoption()``, ``pytest_configure()``, and ``cacheshow()`` functions in ``cacheprovider.py``. \ No newline at end of file diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index dea60109b51..adff6a15930 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -476,6 +476,14 @@ def pytest_sessionfinish(self) -> None: def pytest_addoption(parser: Parser) -> None: + """Add command-line options for cache functionality. + + Adds options for last-failed (--lf), failed-first (--ff), new-first (--nf), + cache display (--cache-show), cache clearing (--cache-clear), and + last-failed-no-failures behavior (--lfnf). Also adds cache_dir ini option. + + :param parser: Parser object to add command-line options to. + """ group = parser.getgroup("general") group.addoption( "--lf", @@ -546,6 +554,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") @@ -584,6 +599,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 From a76e42fafc4c786dc6b0d6e4a78bb6d30430fc88 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 09:53:51 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- changelog/13625.doc.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/13625.doc.rst b/changelog/13625.doc.rst index 961850200ea..850c81583b6 100644 --- a/changelog/13625.doc.rst +++ b/changelog/13625.doc.rst @@ -1 +1 @@ -Added missing docstrings to ``pytest_addoption()``, ``pytest_configure()``, and ``cacheshow()`` functions in ``cacheprovider.py``. \ No newline at end of file +Added missing docstrings to ``pytest_addoption()``, ``pytest_configure()``, and ``cacheshow()`` functions in ``cacheprovider.py``. From 73622e74a7e63858fc6424f3bde8021be6fa0724 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 22 Aug 2025 07:12:14 -0300 Subject: [PATCH 3/3] Update src/_pytest/cacheprovider.py --- src/_pytest/cacheprovider.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index adff6a15930..7f30e72007e 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -478,10 +478,6 @@ def pytest_sessionfinish(self) -> None: def pytest_addoption(parser: Parser) -> None: """Add command-line options for cache functionality. - Adds options for last-failed (--lf), failed-first (--ff), new-first (--nf), - cache display (--cache-show), cache clearing (--cache-clear), and - last-failed-no-failures behavior (--lfnf). Also adds cache_dir ini option. - :param parser: Parser object to add command-line options to. """ group = parser.getgroup("general")