$npx skillfedfor your agent

pytest-antilru

Bust functools.lru_cache when running pytest to avoid test pollution

Worth itPyPI TestingReleased May 2026239.8K downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pytest_antilru-2.0.1-py2.py3-none-any.whl
v2.0.1 · released 2026-05-03 · Python >=3.9 · 1 runtime deps: pytest

Yes. This is a targeted fix for a real problem—test pollution from lru_cache—with low install friction, active maintenance, no vulnerabilities, and permissive licensing. If you use lru_cache in code under test and have experienced test ordering issues or mocking problems, this plugin eliminates the problem with zero code changes.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python >=3.9 and pytest >=3 (pytest <9 for Python 3.9, <10 for Python 3.10+).
  • Low friction install as a pure Python wheel with only pytest as a runtime dependency.
  • Active maintenance with a recent release (103 days ago) and no known vulnerabilities.

License · maintenance · safety

MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.

last release 2026-05-03 (103 days) · last repo commit 2026-05-03 · 33 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 239,801 downloads/mo, #8,915 on PyPI

Verify before relying

pip install pytest-antilru

# Once installed, pytest automatically clears lru_cache between test runs.
# Optional: configure in pytest.ini to target specific modules:
# [tool.pytest.ini_options]
# lru_cache_disabled = 'my_module.util'
  • Whether disabling lru_cache globally (the default) impacts performance of the test suite itself.
  • Behavior when lru_cache is used in third-party dependencies that expect caching to persist across test runs.
Same gist for agents: .md · .json

What it is and what it does

pytest-antilru is a pytest plugin that automatically clears functools.lru_cache between test runs. When you use lru_cache in your application code and then mock or patch dependencies in tests, the cache can retain stale values from previous test runs, causing tests to fail or pass unexpectedly depending on execution order. This plugin solves that by busting the cache between tests, restoring proper test isolation.

The plugin works automatically once installed—no code changes needed. By default it disables lru_cache everywhere, but you can configure an allowlist of specific module paths where caching should remain active, useful when other dependencies rely on cache behavior to function correctly within a single test run.

Use it for

  • Testing functions that use lru_cache with mocked network calls or external dependencies that return different values across test cases.
  • Ensuring test order independence when cached functions are involved, preventing flaky tests that pass or fail based on execution sequence.
  • Selectively disabling cache for specific modules while preserving it in others to avoid breaking dependencies that rely on caching.
  • Debugging test pollution issues caused by persistent cached state from previous test runs.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

This is a targeted fix for a real problem—test pollution from lru_cache—with low install friction, active maintenance, no vulnerabilities, and permissive licensing. If you use lru_cache in code under test and have experienced test ordering issues or mocking problems, this plugin eliminates the problem with zero code changes.

Install

pytest-antilru on PyPI

Before you install

Low friction install as a pure Python wheel with only pytest as a runtime dependency. Active maintenance with a recent release (103 days ago) and no known vulnerabilities.

Requires Python >=3.9 and pytest >=3 (pytest <9 for Python 3.9, <10 for Python 3.10+).

License in practice

MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.

Quickstart

pip install pytest-antilru

# Once installed, pytest automatically clears lru_cache between test runs.
# Optional: configure in pytest.ini to target specific modules:
# [tool.pytest.ini_options]
# lru_cache_disabled = 'my_module.util'

Verify before relying

  • Whether disabling lru_cache globally (the default) impacts performance of the test suite itself.
  • Behavior when lru_cache is used in third-party dependencies that expect caching to persist across test runs.

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.9
Install frictionLow. Pure-Python wheel
Runtime dependencies
1 package
pytest
MaintenanceActively maintained 103 days since the last release
Last repo commit
First released
Downloads239,801 / month, #8,915 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableFramework :: PytestProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9

Evidence: pytest_antilru-2.0.1-py2.py3-none-any.whl

Tags

Capabilities
lru_cache pytest pluginclear cache between teststest isolation cachepytest test pollution fixdisable lru_cache in testsfunctools cache reset pytest
Topics
pytest-plugintest-isolationcache-management

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “lru_cache pytest plugin”

  • pytest-antilruClears functools.lru_cache between pytest test runs to prevent test…
  • functools32Backport of Python 3.2's functools module (including lru_cache…
  • pytest-enablerA pytest plugin that conditionally enables other pytest plugins based…

Give your agent the search over MCP, or paste the wish link into any chat.

More Testing packages

pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
pytest Worth it
PyPI · Libraries · released Jun 2026

pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.

MITpure Python · 3.10+
1.1Bdownloads / mo
virtualenv Worth it
PyPI · Libraries · released Aug 2026

virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.

MITpure Python · 3.9+
532.9Mdownloads / mo
coverage Worth it
PyPI · Testing · released Aug 2026

Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.

Install it if you want to measure test completeness or enforce coverage thresholds in your project.

permissive licensepure Python · 3.10+
335.8Mdownloads / mo
pytest-asyncio Worth it
PyPI · Testing · released May 2026

pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.

Install it if you write tests for any asyncio-based code.

Apache-2.0pure Python · 3.10+
275.9Mdownloads / mo
pytest-json-ctrf Worth it
PyPI · Testing · released Jul 2026

A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.

Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.

MITpure Python · 3.8+
273.0Mdownloads / mo

See also backports.functools-lru-cache · async-lru · methodtools · detect-test-pollution · cachebox · cachetools · onecache · functools32 · memoization · pytest-socket