Skip to main content

pytest-deadfixtures

PyPI - Version PyPI - Python Version pre-commit.ci status


A simple plugin to list unused or duplicated fixtures in a pytest suite.

Features

  • List unused fixtures in your tests
  • List duplicated fixtures
  • Ignore specific fixtures from analysis with @deadfixtures_ignore

Installation

Install pytest-deadfixtures from PyPI:

pip install pytest-deadfixtures

Usage

Important

The --dead-fixtures option does not run your tests and can also be sensitive to errors during the pytest collection step. If using it in CI, run it after the normal test run:

script:
  - pytest
  - pytest --dead-fixtures

Listing unused fixtures

Run pytest with the --dead-fixtures option:

pytest --dead-fixtures
Hey there, I believe the following fixture(s) are not being used:
Fixture name: some_fixture, location: test_write_docs_when_verbose.py:5

no tests ran

Use verbosity to include fixture docstrings in the report:

pytest --dead-fixtures -v

Listing repeated fixtures

The --dup-fixtures option compares fixture return values to find possible duplicates. Fixtures without a truthy return value are skipped. Treat the report as a hint and verify that the fixtures provide the same functionality before removing one.

Unlike --dead-fixtures, this option runs the tests:

pytest --dup-fixtures
tests/test_deadfixtures.py ........

You may have some duplicate fixtures:
Fixture name: someclass_fixture, location: test_repeated_fixtures.py:12
Fixture name: someclass_samefixture, location: test_repeated_fixtures.py:17

Ignoring specific fixtures

Use the @deadfixtures_ignore decorator to exclude a fixture from the analysis:

import pytest

from pytest_deadfixtures import deadfixtures_ignore


@pytest.fixture
@deadfixtures_ignore
def intentionally_unused_fixture():
    """This fixture won't be reported as unused."""
    return "something"

To see which fixtures are ignored, use --show-ignored-fixtures:

pytest --dead-fixtures --show-ignored-fixtures
No unused fixtures found. Great job!

Ignored fixture(s) 1:
Fixture name: intentionally_unused_fixture, location: conftest.py:10

Projects using it

Contributing

Contributions are welcome. Run the tests with hatch test and check the code with hatch check code before submitting a pull request.

License

Distributed under the terms of the MIT License. pytest-deadfixtures is free and open source software.

Issues

If you encounter any problems, file an issue with a detailed description.

Metadata

Release files for pytest-deadfixtures 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-deadfixtures 4.0.0
File Size Uploaded Provenance Actions
pytest_deadfixtures-4.0.0.tar.gz 12.5 kB With provenance Details for pytest_deadfixtures-4.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-deadfixtures 4.0.0
File Interpreter ABI Platform Actions
pytest_deadfixtures-4.0.0-py3-none-any.whl Python 3 none any Details for pytest_deadfixtures-4.0.0-py3-none-any.whl

Total release size: 19.6 kB

Release files / pytest_deadfixtures-4.0.0.tar.gz

Download URL pytest_deadfixtures-4.0.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0ea8cb729774b91332eecdfd85508d3d5562a4ecc762b668f422c9f7c6d0802d
BLAKE2b-256 checksum
How to use checksums
28c48d10bdc376aed9da4b69ccfb95b758e6e0cacfdf2285c5e09ac2a5b17b5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / pytest_deadfixtures-4.0.0-py3-none-any.whl

Download URL pytest_deadfixtures-4.0.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d00d80ac5dae8a2c707e915f68c10e0121acc7c2f001844f394e7dc94db533c
BLAKE2b-256 checksum
How to use checksums
db2446f92f4c3659309ea34f0c3743fe9347af08f2b5df8ecb281e772e23afad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for pytest-deadfixtures 4.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_deadfixtures-4.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page