Pytest plugin to easily fake missing modules
Project description
pytest-missing-modules
Minimalist Pytest plugin that adds a fixture to fake missing modules.
Who should use this plugin
Sometimes, your code needs to handle the possibility that an optional dependency can be missing, e.g., you develop a plotting library supporting multiple drawing backends.
This plugin provides a convenient way to simulate one
or multiple missing modules, raising an ImportError instead.
Usage
First, install this plugin with:
pip install pytest-missing-modules
Then, you use the Pytest fixtures like so:
# this should be in one of your test files
import importlib
import my_package
def test_missing_numpy(missing_modules):
with missing_modules("numpy"):
# Check that you can still import your package, without NumPy!
importlib.reload(my_package)
If you need, you can also add type hints to your code:
from pytest_missing_modules.plugin import MissingModulesContextGenerator
def test_missing_package(missing_modules: MissingModulesContextGenerator):
# your test logic goes here
For more advance usage, please check the documentation.
Contributing
This project welcomes any contribution, and especially:
- bug fixes;
- or documentation typos.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_missing_modules-0.2.2.tar.gz.
File metadata
- Download URL: pytest_missing_modules-0.2.2.tar.gz
- Upload date:
- Size: 98.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d23252e1d5f9e4dff1b58448e5d70cc66aa209258338e7c006756af412cafd45
|
|
| MD5 |
9e7a8e4ba94d1a39b4c965ca5a25168a
|
|
| BLAKE2b-256 |
8a91d3f4a045170269e3491a49946e9c824cfcc8d2303c83521c86f11fa422a3
|
Provenance
The following attestation bundles were made for pytest_missing_modules-0.2.2.tar.gz:
Publisher:
publish.yml on jeertmans/pytest-missing-modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_missing_modules-0.2.2.tar.gz -
Subject digest:
d23252e1d5f9e4dff1b58448e5d70cc66aa209258338e7c006756af412cafd45 - Sigstore transparency entry: 705344715
- Sigstore integration time:
-
Permalink:
jeertmans/pytest-missing-modules@2d945c36cfab9d7e12850a15ab11b778692ae6fd -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/jeertmans
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2d945c36cfab9d7e12850a15ab11b778692ae6fd -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_missing_modules-0.2.2-py3-none-any.whl.
File metadata
- Download URL: pytest_missing_modules-0.2.2-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b95797ecb3b6af72c9f634a1c40c043a5f4b78aef5292e5d8dc2cbb7ed5f491b
|
|
| MD5 |
2f77d301395825d4346426204db8711e
|
|
| BLAKE2b-256 |
36978634f8bc5cfb899c53f13748e68fa5bb374dd8f6381c09bd3384c7233dd9
|
Provenance
The following attestation bundles were made for pytest_missing_modules-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on jeertmans/pytest-missing-modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_missing_modules-0.2.2-py3-none-any.whl -
Subject digest:
b95797ecb3b6af72c9f634a1c40c043a5f4b78aef5292e5d8dc2cbb7ed5f491b - Sigstore transparency entry: 705344721
- Sigstore integration time:
-
Permalink:
jeertmans/pytest-missing-modules@2d945c36cfab9d7e12850a15ab11b778692ae6fd -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/jeertmans
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2d945c36cfab9d7e12850a15ab11b778692ae6fd -
Trigger Event:
push
-
Statement type: