
Security News
Research
Destructive npm Packages Disguised as Utilities Enable Remote System Wipe
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
pytest-missing-modules
Advanced tools
Minimalist Pytest plugin that adds a fixture to fake missing modules.
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.
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.
This project welcomes any contribution, and especially:
FAQs
Pytest plugin to easily fake missing modules
We found that pytest-missing-modules demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.
Research
Security News
Socket uncovered four malicious npm packages that exfiltrate up to 85% of a victim’s Ethereum or BSC wallet using obfuscated JavaScript.