Metadata-Version: 2.5
Name: pytest-optional-dependencies
Version: 0.2.1
Summary: 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.
Project-URL: Homepage, https://github.com/okken/pytest-optional-dependencies
Project-URL: Repository, https://github.com/okken/pytest-optional-dependencies
Project-URL: Issues, https://github.com/okken/pytest-optional-dependencies/issues
Author: Brian Okken
License: MIT License
        
        Copyright (c) collect-filter contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: collection,imports,plugin,pytest,testing
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Requires-Dist: pytest>=8.0
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: tox; extra == 'dev'
Requires-Dist: tox-uv; extra == 'dev'
Description-Content-Type: text/markdown

# 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

```bash
uv pip install pytest-optional-dependencies
```

Or with pip:

```bash
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:

```ini
[pytest]
optional_dependencies =
    optional_dependency
    some_namespace.submodule
optional_dependencies_any = false
optional_dependencies_action = skip
```

pyproject.toml:

```toml
[tool.pytest.ini_options]
optional_dependencies = [
  "optional_dependency",
  "some_namespace.submodule",
]
optional_dependencies_any = false
optional_dependencies_action = "skip"
```

## Example

```bash
pytest -q --optional-dependency optional_dependency --report-optional-dependencies
pytest -q --optional-dependency optional_dependency --optional-dependencies-action skip
```

## Development

```bash
python -m pytest -q
```

## License

MIT. See LICENSE.
