Skip to main content

A mocking functions for imports

Project description

https://travis-ci.org/posener/mock-import.svg?branch=master https://badge.fury.io/py/mock-import.svg

A helper function to mask ImportError s on a scoped code, using the with statement, or in method a method used as a decorator. Failed imports will be ignored, unless specified by the do_not_mock argument.

The do_not_mock argument is a package or module name, or package or module names list. When specified, and imported in the scoped mocked code, importing them must succeed. If None (the default) then no import must succeed.

Mocking import for a code block:
>>> with mock_import():
...     import do_not_exists
Mocking import as a decorator:
>>> @mock_import()
... def method():
...     import do_not_exists

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

mock-import-0.0.2.tar.gz (1.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page