{"id":24439,"library":"pytest-unused-fixtures","title":"pytest-unused-fixtures","description":"A pytest plugin that lists fixtures defined but not used in a test run. Useful for keeping test suites clean. Current version: 0.3.1. Requires Python >=3.9. Maintained, release cadence is irregular.","status":"active","version":"0.3.1","language":"python","source_language":"en","source_url":"https://github.com/mikicz/pytest-unused-fixtures","tags":["pytest","plugin","fixtures","cleanup","testing"],"install":[{"cmd":"pip install pytest-unused-fixtures","lang":"bash","label":"Default install"}],"dependencies":[],"imports":[{"note":"Exposed as a public symbol since v0.3.0.","wrong":null,"symbol":"ignore_unused_fixture","correct":"from pytest_unused_fixtures import ignore_unused_fixture"}],"quickstart":{"code":"import pytest\n\n# conftest.py or test file\n@pytest.fixture\ndef used_fixture():\n    return 1\n\n@pytest.fixture\ndef unused_fixture():\n    return 2\n\ndef test_foo(used_fixture):\n    assert used_fixture == 1\n\n# Run pytest --unused-fixtures to see 'unused_fixture' listed.\n# To ignore a fixture from this check, decorate with @ignore_unused_fixture","lang":"python","description":"Basic usage: define fixtures, run `pytest --unused-fixtures`, and optionally ignore specific ones."},"warnings":[{"fix":"Ensure your fixture is defined in the test suite (e.g., conftest.py or test module).","message":"The plugin only reports fixtures that are defined in the same session but never requested. Fixtures from installed packages (e.g., built-in plugins) are not considered unless they are explicitly loaded.","severity":"gotcha","affected_versions":"all"},{"fix":"Update your custom checks to handle an empty set instead of `None`.","message":"In v0.3.0, the default value of `available_fixtures` changed from `None` to an empty set. If you were relying on `None` in custom code that uses the plugin's internals, your code may break.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"No action needed.","message":"The `--unused-fixtures` CLI option is the only interface. No deprecated options exist as of v0.3.1.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade to 0.3.0 or later: `pip install --upgrade pytest-unused-fixtures`","cause":"Using an older version (<0.3.0) that does not have the `ignore_unused_fixture` decorator.","error":"AttributeError: module 'pytest_unused_fixtures' has no attribute 'ignore_unused_fixture'"},{"fix":"This is expected behavior. Use `@ignore_unused_fixture` on fixtures you don't want flagged.","cause":"The plugin only captures fixtures defined in the test suite, not fixtures from installed plugins or conftest.py of other packages.","error":"Fixtures imported from third-party packages appear as unused"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}