Display cachedir with --cache-show and if non-default.
(config: Config)
| 523 | |
| 524 | |
| 525 | def pytest_report_header(config: Config) -> Optional[str]: |
| 526 | """Display cachedir with --cache-show and if non-default.""" |
| 527 | if config.option.verbose > 0 or config.getini("cache_dir") != ".pytest_cache": |
| 528 | assert config.cache is not None |
| 529 | cachedir = config.cache._cachedir |
| 530 | # TODO: evaluate generating upward relative paths |
| 531 | # starting with .., ../.. if sensible |
| 532 | |
| 533 | try: |
| 534 | displaypath = cachedir.relative_to(config.rootpath) |
| 535 | except ValueError: |
| 536 | displaypath = cachedir |
| 537 | return f"cachedir: {displaypath}" |
| 538 | return None |
| 539 | |
| 540 | |
| 541 | def cacheshow(config: Config, session: Session) -> int: |