Skip to main content

This plugin enables you to run vulture (https://pypi.org/project/vulture/) alongside pytest, allowing for dead code detection during your testing process.

Sample Usage

To integrate vulture with pytest and find dead code, use the following commands:

  1. Basic Usage Run vulture with pytest to check for dead code:

    pytest --vulture
  2. Custom Configuration Specify a custom configuration file path:

    pytest --vulture --vulture-cfg-file=/path/to/vulture.ini

    Note: By default, the tool looks for configuration files in the following order:

    • pyproject.toml

    • tox.ini

    • vulture.ini

Ignoring Vulture Messages

You can ignore specific warnings from vulture directly in the source code. Here’s how:

  • Ignore Specific Lines:

    def test_function():
        unused_variable = 42  # vulture: ignore
  • Ignore Entire Methods:

    def ignored_function():  # vulture: ignore
        pass
  • Ignore Classes:

    class IgnoredClass:  # vulture: ignore
        pass

Configuring with pyproject.toml

Here’s an example of how to configure vulture using pyproject.toml:

[tool.vulture]
# Exclude specific paths (e.g., test directories)
exclude = [
    "*/test/*",
]

# Ignore specific files in the `pytest` output (but they are still checked by `vulture`)
ignore = [
    "src/some_ignored_file.py",
]

# Ignore specific function or variable names
ignore-names = [
    "deprecated_function",
]

# Ignore decorators
ignore-decorators = [
    "@app.route",
    "@celery.task",
]

# Ignore specific types of messages (e.g., imports)
ignore-types = [
    "import",
]

# Define the source path
source-path = "src"

Configuring with .ini Config Files

Here’s an example of how to configure vulture using an .ini file:

[vulture]
exclude =
    */test/*  # Usually exclude tests as they may cover dead code

ignore =
    src/some_ignored_file.py

ignore-names =
    deprecated_function

ignore-decorators =
    @app.route
    @celery.task

ignore-types =
    attribute
    variable

Acknowledgements

This code depends on vulture

Development

If you want to help development, there is overview documentation in DEVELOPMENT.rst.

Issues

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

Releases

2.2.0

  • Add pyproject.toml support for parameters

2.0.2

  • Uses vulture with pytest (tested with python 3.7 3.8 and 3.9, with vulture==2.3 and pytest 7.x)

1.0.0

  • stable Gatewatcher internal use only

0.x

  • unstable Gatewatcher internal use only

Release files for pytest-vulture 2.2.2

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-vulture 2.2.2
File Size Uploaded
pytest_vulture-2.2.2.tar.gz 54.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-vulture 2.2.2
File Interpreter ABI Platform
pytest_vulture-2.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 68.7 kB

Release files / pytest_vulture-2.2.2.tar.gz

Download URL pytest_vulture-2.2.2.tar.gz
Size 54.1 kB
Tags Source
SHA-256 checksum
How to use checksums
33ecaac6a2a62f14bc5d49a3f4bb254ae730f4d1ee3c799924e4aa32d1ea1b97
BLAKE2b-256 checksum
How to use checksums
943ad26192cbd8577c7fc72986d0a0bedb7241115d82640e5db28a77224fe53d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.4

Release files / pytest_vulture-2.2.2-py3-none-any.whl

Download URL pytest_vulture-2.2.2-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac5aff94adc9a40de0d689f5640c92b15c2a42a2399a60c01bc06369fc7e685e
BLAKE2b-256 checksum
How to use checksums
0d1ee041078191aa4003d71583c1382ef8580b549e58e8f7878b76f52fbfa664
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.4

Release history Release notifications | RSS feed

This release

2.2.2 This release

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

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