pytest-optional-dependencies
Don't test code that won't load due to missing imports. A pytest plugin to skip tests that require optional dependencies that are not installed.
Collection-time optional dependency handling for pytest.
This plugin allows specific missing imports to be treated as optional so collection can continue without errors.
Features
- --optional-dependency MODULE (repeatable, also accepts comma-separated values).
- specify which dependencies to skip/deselect based on their absence
- --optional-dependencies-any
- to treat any missing module import as optional.
- --optional-dependencies-action
- to control optional import handling: skip (default) or deselect.
- Configuration options
- optional_dependencies
- optional_dependencies_any
- optional_dependencies_action
- --report-optional-dependencies
- Report what was filtered and why.
Install
uv pip install pytest-optional-dependencies
Or with pip:
python -m pip install pytest-optional-dependencies
Compatibility
- Python: 3.10+
- pytest: 8.0+
CLI options
- --optional-dependency MODULE
- --optional-dependencies-any
- --optional-dependencies-action {deselect,skip}
- --report-optional-dependencies
Configuration
pytest.ini:
[pytest]
optional_dependencies =
optional_dependency
some_namespace.submodule
optional_dependencies_any = false
optional_dependencies_action = skip
pyproject.toml:
[tool.pytest.ini_options]
optional_dependencies = [
"optional_dependency",
"some_namespace.submodule",
]
optional_dependencies_any = false
optional_dependencies_action = "skip"
Example
pytest -q --optional-dependency optional_dependency --report-optional-dependencies
pytest -q --optional-dependency optional_dependency --optional-dependencies-action skip
Development
python -m pytest -q
License
MIT. See LICENSE.
Metadata
Release files for pytest-optional-dependencies 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pytest_optional_dependencies-0.2.1.tar.gz | 10.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_optional_dependencies-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.8 kB
Release files / pytest_optional_dependencies-0.2.1.tar.gz
| Download URL | pytest_optional_dependencies-0.2.1.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3676093c9ac5868298e1f639912c287bed79379842f259ee50e66cd299d9531
|
|
BLAKE2b-256 checksum How to use checksums |
5d599b82c8e314b33b659a63e9be4bce7caf69439d9d5195a26cedab3c0179e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 15, 2026.
Transparency logRelease files / pytest_optional_dependencies-0.2.1-py3-none-any.whl
| Download URL | pytest_optional_dependencies-0.2.1-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9643966861ec376dcc3964af52b0bcce9f4f834bb00fc2d2507a9682f5cf2b8
|
|
BLAKE2b-256 checksum How to use checksums |
ded84866b68205f33257caae14e02c640d26efaea4a1d05f63010be12c758130
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 15, 2026.
Transparency logSecurity for pytest-optional-dependencies 0.2.1
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.
Attestation for pytest_optional_dependencies-0.2.1.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 15, 2026.
Transparency logA 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.