pytest-unused-fixtures
A pytest plugin to list unused fixtures after a test run.
What it is and what it does
pytest-unused-fixtures is a pytest plugin that runs after your tests complete and compares all fixtures available in your test collection against those actually used during the test run. It then reports which fixtures were never invoked, grouped by their definition location. This helps identify dead code in your test fixtures that can be safely removed or refactored.
The plugin requires actual test execution to work accurately because pytest supports dynamic fixture requests that static analysis cannot catch. You enable it by passing the `--unused-fixtures` flag to pytest. It offers several configuration options: you can ignore specific paths, limit the scan to particular directories, mark individual fixtures to skip reporting with a decorator, and optionally fail the test session if unused fixtures are found.
Use it for:
- Clean up test fixture cruft by identifying fixtures that were created but never actually used in any test.
- Enforce fixture hygiene in CI/CD by failing the build when unused fixtures are detected, using `--unused-fixtures-fail-when-present`.
- Scope fixture analysis to specific test directories to focus cleanup efforts on particular modules or packages.
- Exclude intentionally unused fixtures (e.g., those reserved for skipped tests) using the `@ignore_unused_fixture` decorator.
- Audit legacy test suites to understand which fixtures are truly active versus which can be removed.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that identifies and reports fixtures defined in your test suite that are never actually used during test execution.
Yes. This is a low-friction, actively maintained plugin that solves a real test maintenance problem—identifying dead fixture code—with no security concerns and a permissive license. It integrates seamlessly into pytest workflows and is useful for any project that wants to keep its test fixtures clean and intentional.
Install
pytest-unused-fixtures on PyPI
pip
pip install pytest-unused-fixturesuv
uv add pytest-unused-fixturespoetry
poetry add pytest-unused-fixturesInstalling pytest-unused-fixtures
Before you install
Low friction install as a pure Python wheel with only pytest as a runtime dependency. The project is actively maintained with recent releases and a clean commit history.
License in practice
MIT license is permissive; you can use this plugin freely in commercial and private projects with minimal restrictions.
Quickstart
pip install pytest-unused-fixtures
pytest tests --unused-fixtures
# To fail the test session if unused fixtures are found:
pytest tests --unused-fixtures --unused-fixtures-fail-when-present
Requires pytest to be installed; the plugin only works as a pytest plugin and cannot be used standalone.
Verify before relying
- Whether the plugin accurately detects fixtures used via dynamic pytest mechanisms beyond simple parameter injection.
- Performance impact when scanning large test suites with many fixtures.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pytest |
| Maintenance | actively maintained — 234 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 317,150/month — #7,665 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_unused_fixtures-0.3.1-py3-none-any.whl
Keywords: pytest, fixtures
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-deadfixturesA pytest plugin that identifies unused and…
permissive · top 5,000 on PyPI
fixturesProvides a reusable fixture contract for unit…
permissive · top 15,000 on PyPI
pytest-printAdds fixtures to pytest that print messages…
permissive · top 15,000 on PyPI
cppcleancppclean analyzes C++ source code to identify…
permissive · top 15,000 on PyPI
pytest-durationsA pytest plugin that measures and reports…
permissive · top 5,000 on PyPI
pytest-dockerpytest-docker provides pytest fixtures that…
permissive · top 5,000 on PyPI
pylint-pytestA Pylint plugin that suppresses false-positive…
permissive · top 15,000 on PyPI
pytest-lazy-fixturesAllows you to reference pytest fixtures…
permissive · top 5,000 on PyPI
pytest-shutilProvides pytest fixtures and utilities for…
permissive · top 15,000 on PyPI
pytest-homeassistant-custom-componentProvides pytest fixtures and testing utilities…
permissive · top 5,000 on PyPI