{"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":"python","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,"search_vec":"'1.0':76 '2.8':61 '2013':79 '3.8':63 'abandon':83 'across':19 'around':59 'cach':3,6,17,72,95 'config.cache':41 'core':51,92 'data':18 'deprec':97 'effect':82 'extern':9 'fail':30,35 'featur':86 'ff':38 'first':37 'function':52 'includ':22 'integr':54 'june':78 'last':29,65 'lf':32 'make':80 'mechan':15 'object':42 'option':23 'part':89 'plugin':10,44,73,96 'provid':14 'pytest':2,5,12,56,71,91,93 'pytest-cach':1,4,70 're':26 're-run':25 'releas':66 'retriev':48 'run':21,27,34 'standalon':69 'start':58 'store':46 'test':20,31,36,94 'valu':49 'version':60,75","created_at":"2026-04-14T18:46:14.291455+00:00","updated_at":"2026-04-16T19:57:17.939036+00:00","problems":[{"fix":"Remove the `pytest-cache` dependency from your project's requirements and update any code that explicitly imports it. Use `pytest`'s built-in caching mechanism (e.g., via `request.config.cache`) directly.","cause":"An outdated project or configuration is attempting to import or depend on the standalone `pytest-cache` plugin, but it is not installed or has been explicitly removed, as its functionality is now integrated into `pytest` core.","error":"ModuleNotFoundError: No module named 'pytest_cache'"},{"fix":"Upgrade `pytest` to a modern version (e.g., `pip install --upgrade pytest`). The `--lf` option has been part of core `pytest` since version 2.8, and `--ff` (failed first) since 3.8.","cause":"The user is attempting to use the `--lf` (last failed) command-line option, but the installed `pytest` version is too old to have this option built-in, and the standalone `pytest-cache` plugin (which originally provided it) is either not installed or not active.","error":"unknown option: --lf"},{"fix":"Uninstall the standalone `pytest-cache` plugin (`pip uninstall pytest-cache`). The caching features, including `--lf`, `--ff`, and `request.config.cache`, are available directly through your `pytest` installation.","cause":"This warning occurs when the standalone `pytest-cache` plugin is still installed and detected in an environment using a modern `pytest` version, indicating that the plugin is redundant because its features are now part of `pytest` core.","error":"UserWarning: The pytest-cache plugin is deprecated. Its functionality is now built into pytest."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"http://bitbucket.org/hpk42/pytest-cache/","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/pytest-cache/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-04-14","next_check":"2026-07-13","install_tag":null}}