Skip to main content

Highly useful utilities for mocking execution flow during unit test execution.

Project description

mocking-utils

release build coverage dependencies

Highly useful utilities for mocking execution flow during unit test execution.

Quick Start

Installation

pip install mocking-utils

Usage

from mocking_utils import MockFunction

class A(object):
    def my_method(self):
        print('I am in my_method')

a = A()
a.my_method()  # Out: 'I am in my_method'
mock = MockFunction(A, 'my_method', lambda x: print('lambda function'), call=True)
a.my_method()  # Out: 'lambda function'
mock.reset()
a.my_method()  # Out: 'I am in my_method'

Examples

pytest

from mocking_utils import MockFunction

@pytest.fixture(scope='module', autouse=True)
def setup__teardown():
    """
    Standard setup & teardown within a module of unit tests.
    """
    mocks = [
        MockFunction(A, 'my_method', lambda x: print('lambda function'), call=True)
        ]
    yield 'Setup complete'
    [mock.reset() for mock in mocks]

Testing & Code Quality

Code coverage reports for master, branches, and PRs are posted here in CodeCov.

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

mocking-utils-1.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

mocking_utils-1.1.0-py2-none-any.whl (6.9 kB view details)

Uploaded Python 2

File details

Details for the file mocking-utils-1.1.0.tar.gz.

File metadata

  • Download URL: mocking-utils-1.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/2.7.15

File hashes

Hashes for mocking-utils-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f87f5a2bde20402d1687b5b319c8cd57d38d33387372a032767107680907b417
MD5 a111eacf04d2dc38e895200a8eef8bf2
BLAKE2b-256 24698541c00f6ceeabf114b0106db2b36318e4bd3c4de52b13914fd2efa645d3

See more details on using hashes here.

File details

Details for the file mocking_utils-1.1.0-py2-none-any.whl.

File metadata

  • Download URL: mocking_utils-1.1.0-py2-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/2.7.15

File hashes

Hashes for mocking_utils-1.1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 bf2bfff41457694b24f7cc1ffe8bbe31c09d79f697be8f713014b0fce0a4d72f
MD5 7a3cd5217a1b4c2f6f2d8955f7c0f4ea
BLAKE2b-256 80e2fd6223a21c31a0ae6e14c8f645195c7c185d0db38b45553c11533ec95a53

See more details on using hashes here.

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