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.2.1.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

mocking_utils-1.2.1-py2-none-any.whl (7.0 kB view hashes)

Uploaded Python 2

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