{"id":6198,"library":"pytest-cache","title":"pytest-cache","description":"pytest-cache was an external plugin for pytest that provided mechanisms for caching data across test runs, including options to re-run only last failed tests (`--lf`) or run failed tests first (`--ff`), and a `config.cache` object for plugins to store and retrieve values. Its core functionality was integrated into pytest itself starting around versions 2.8 and 3.8. The last release of the standalone `pytest-cache` plugin was version 1.0 in June 2013, making it effectively abandoned as its features are now part of `pytest` core.","status":"abandoned","version":"1.0","language":"en","source_language":"en","source_url":"https://github.com/longlho/pytest-cache","tags":["pytest","testing","cache","plugin","deprecated"],"install":[{"cmd":"pip install pytest-cache","lang":"bash","label":"Install (Discouraged)"}],"dependencies":[],"imports":[],"quickstart":{"code":"# The functionality of pytest-cache is now built into pytest.\n# To access the cache in modern pytest:\n\ndef test_example_with_cache(cache):\n    # Get a value from the cache, with a default if not found\n    cached_value = cache.get('myplugin/some_key', 'default_value')\n    print(f\"Cached value: {cached_value}\")\n\n    # Set a value in the cache\n    cache.set('myplugin/some_key', 'new_value')\n\n# To run only last failed tests:\n# pytest --lf\n\n# To run failed tests first, then the rest:\n# pytest --ff\n\n# To clear the cache:\n# pytest --cache-clear","lang":"python","description":"This quickstart demonstrates how to use the caching mechanisms directly provided by modern pytest, which supersede the `pytest-cache` plugin. It shows how to access the `cache` fixture, and common command-line options for test re-running and cache management."},"warnings":[{"fix":"Remove `pytest-cache` from your dependencies. Use `pytest`'s built-in `cache` fixture and command-line options. For example, `from _pytest.cacheprovider import Cache` is an internal import, but the `cache` fixture is the public API.","message":"The standalone `pytest-cache` plugin is obsolete. Its core functionalities, such as the `cache` fixture and command-line options like `--lf` (last failed) and `--ff` (failed first), were integrated directly into `pytest` starting with `pytest` 2.8 and later refined. Directly installing and using `pytest-cache` with modern `pytest` versions is not recommended and may lead to unexpected behavior or conflicts.","severity":"breaking","affected_versions":"<= 1.0 (external plugin), >= 2.8 (pytest core integration)"},{"fix":"Do not install `pytest-cache`. Ensure your `pytest` installation is up-to-date to benefit from the integrated caching features.","message":"The `pytest-cache` plugin itself has not been updated since June 2013 (version 1.0) and is considered abandoned. All its relevant features are now maintained and provided by the `pytest` core. Relying on this old, external plugin is unnecessary and potentially insecure.","severity":"deprecated","affected_versions":"All versions of `pytest-cache`."},{"fix":"Ensure `.pytest_cache/` is added to your project's `.gitignore` if `pytest` does not automatically create one, to prevent committing cache files. Understand that `pytest` manages this directory for cross-session state.","message":"The cache directory for `pytest` was renamed from `.cache` to `.pytest_cache` to clarify its purpose. If migrating from very old `pytest-cache` setups, be aware of this change. The `.pytest_cache` directory is typically created in the project's root directory and should generally be ignored by version control systems, although `pytest` now often adds a `.gitignore` file within it automatically.","severity":"gotcha","affected_versions":"All versions of `pytest` that use built-in caching (>= 2.8)."}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}