@@ -476,6 +476,10 @@ def pytest_sessionfinish(self) -> None:
476
476
477
477
478
478
def pytest_addoption (parser : Parser ) -> None :
479
+ """Add command-line options for cache functionality.
480
+
481
+ :param parser: Parser object to add command-line options to.
482
+ """
479
483
group = parser .getgroup ("general" )
480
484
group .addoption (
481
485
"--lf" ,
@@ -546,6 +550,13 @@ def pytest_cmdline_main(config: Config) -> int | ExitCode | None:
546
550
547
551
@hookimpl (tryfirst = True )
548
552
def pytest_configure (config : Config ) -> None :
553
+ """Configure cache system and register related plugins.
554
+
555
+ Creates the Cache instance and registers the last-failed (LFPlugin)
556
+ and new-first (NFPlugin) plugins with the plugin manager.
557
+
558
+ :param config: pytest configuration object.
559
+ """
549
560
config .cache = Cache .for_config (config , _ispytest = True )
550
561
config .pluginmanager .register (LFPlugin (config ), "lfplugin" )
551
562
config .pluginmanager .register (NFPlugin (config ), "nfplugin" )
@@ -584,6 +595,16 @@ def pytest_report_header(config: Config) -> str | None:
584
595
585
596
586
597
def cacheshow (config : Config , session : Session ) -> int :
598
+ """Display cache contents when --cache-show is used.
599
+
600
+ Shows cached values and directories matching the specified glob pattern
601
+ (default: '*'). Displays cache location, cached test results, and
602
+ any cached directories created by plugins.
603
+
604
+ :param config: pytest configuration object.
605
+ :param session: pytest session object.
606
+ :returns: Exit code (0 for success).
607
+ """
587
608
from pprint import pformat
588
609
589
610
assert config .cache is not None
0 commit comments