Skip to main content

Stub packages, modules and attributes.

Project description

release lic ci coverage health


Stub packages, modules and attributes.

This pytest plugin allows you to replace dependencies with stubs.

It can be useful if you want to test some code using a dependency without actually having this dependency, for example if you’re testing your library, which uses some parts of another library.


  • Python 3
  • pytest >= 2.9.0

How to use

Use stub fixture in your test functions, like this:

def test_django_related(stub):

        # Replace `call_command` with a generated function.
        '': '[func]',

        # Replace `BaseCommand` with a generated class.
        '': '[cls]',

        # Stub multiple attributes in the same module with custom objects.
        'django.conf': {
            'settings': object(),
            'some': True,


You can stub dependencies either with your own custom objects or you may instruct pytest-stub to generate functions or classes for you.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pytest-stub, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size pytest_stub-0.1.0-py2.py3-none-any.whl (5.5 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size pytest-stub-0.1.0.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page