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.
Release files for pytest-missing-modules 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_missing_modules-0.2.2.tar.gz | 98.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_missing_modules-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 103.7 kB
Release files / pytest_missing_modules-0.2.2.tar.gz
| Download URL | pytest_missing_modules-0.2.2.tar.gz |
|---|---|
| Size | 98.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d23252e1d5f9e4dff1b58448e5d70cc66aa209258338e7c006756af412cafd45
|
|
BLAKE2b-256 checksum How to use checksums |
8a91d3f4a045170269e3491a49946e9c824cfcc8d2303c83521c86f11fa422a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Nov 17, 2025.
Transparency logRelease files / pytest_missing_modules-0.2.2-py3-none-any.whl
| Download URL | pytest_missing_modules-0.2.2-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b95797ecb3b6af72c9f634a1c40c043a5f4b78aef5292e5d8dc2cbb7ed5f491b
|
|
BLAKE2b-256 checksum How to use checksums |
36978634f8bc5cfb899c53f13748e68fa5bb374dd8f6381c09bd3384c7233dd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Nov 17, 2025.
Transparency log