Skip to main content

Stub packages, modules and attributes.

Project description

https://github.com/idlesign/pytest-stub

release lic ci coverage health

Description

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.

Requirements

  • Python 3

  • pytest >= 2.9.0

How to use

Use stub fixture in your test functions, like this:

def test_django_related(stub):

    stub.apply({
        # Replace `call_command` with a generated function.
        'django.core.management.call_command': '[func]',

        # Replace `BaseCommand` with a generated class.
        'django.core.management.base.BaseCommand': '[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.

Source Distribution

pytest-stub-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_stub-0.1.0-py2.py3-none-any.whl (5.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest-stub-0.1.0.tar.gz.

File metadata

  • Download URL: pytest-stub-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for pytest-stub-0.1.0.tar.gz
Algorithm Hash digest
SHA256 849f9c8007e68b542b96db833037749a49e9d66c413a01dc5302510e62202d5e
MD5 05a0dcea0c12051cf6eaf5be76e9ae93
BLAKE2b-256 dae4dbce55853783e57b752d0b845ae560ce5b4a3f78519fce7efe3b05ec17e4

See more details on using hashes here.

File details

Details for the file pytest_stub-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_stub-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0d5ecfaa01cc3682a3292b112e9c2d0223de69a43b29502b7568cb4e3c6635a5
MD5 f00baf3c27164ebd92e4528223bcffb0
BLAKE2b-256 3b6cab2ef432045e223b4cf424aa40ca04f4835a788c5aef27d82d9896b06a8f

See more details on using hashes here.

Supported by

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