{"id":24415,"library":"pytest-antilru","title":"pytest-antilru","description":"Bust functools.lru_cache when running pytest to avoid test pollution. Version 2.0.0 dropped Python 2.7 and 3.5–3.7, added Python 3.10–3.13 support, and introduced the 'lru_cache_disabled' config option. Maintained on GitHub.","status":"active","version":"2.0.0","language":"python","source_language":"en","source_url":"https://github.com/ipwnponies/pytest-antilru","tags":["pytest","lru_cache","testing","fixture"],"install":[{"cmd":"pip install pytest-antilru","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The plugin is auto-detected by pytest via entrypoints; no explicit import needed.","wrong":"import pytest_antilru  # no wrong pattern, plugin auto-loads","symbol":"pytest_antilru","correct":"import pytest_antilru"}],"quickstart":{"code":"# Install: pip install pytest-antilru\n# Then just run pytest normally; lru_cache is busted per test session.\n\ndef test_example():\n    # lru_cache will be cleared before each test\n    from mymodule import cached_func\n    assert cached_func(1) == cached_func(1)  # still works within test\n","lang":"python","description":"After installation, `pytest-antilru` automatically busts all `functools.lru_cache` caches between tests to prevent state leakage."},"warnings":[{"fix":"Upgrade to Python >=3.8 and use v2.0.0.","message":"Version 2.0 drops Python 2.7, 3.5, 3.6, 3.7. Only Python >=3.8 supported.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Ensure pytest-antilru is installed; no manual entrypoint config needed.","message":"The old entrypoint name 'pytest-antilru' was incorrect in v1.0.x; fixed in v1.1.1. If you manually configured entrypoints, update.","severity":"deprecated","affected_versions":">=1.0.0, <1.1.1"},{"fix":"No fix needed; it's by design. Use `lru_cache_disabled` config option in v2 to selectively skip modules.","message":"If you use `lru_cache` with `maxsize=None` (or as a plain decorator), the cache is still busted. This is intended but may surprise users who expect unbounded caches to persist.","severity":"gotcha","affected_versions":"all"},{"fix":"Manually call `.cache_clear()` on `functools.cache` or `cached_property` if needed.","message":"The plugin does not bust caches for `functools.cache` (Python 3.9+) or `functools.cached_property`. Only `lru_cache` unwrapped and wrapped with parentheses are handled.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Remove `import pytest_antilru` from your conftest or test files; it auto-discovers via entrypoints.","cause":"Explicitly importing pytest_antilru when not needed. The plugin is loaded automatically.","error":"ModuleNotFoundError: No module named 'pytest_antilru'"},{"fix":"Upgrade to Python >=3.8 or use `@lru_cache()` with parentheses.","cause":"Using the plugin on functions decorated with `@lru_cache` (without parentheses) before Python 3.8. The plugin relies on the wrapper object.","error":"AttributeError: 'function' object has no attribute 'cache_clear'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}