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 details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 2

File details

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

File metadata

  • Download URL: mocking-utils-1.2.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.7.1 requests/2.26.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/2.7.16

File hashes

Hashes for mocking-utils-1.2.1.tar.gz
Algorithm Hash digest
SHA256 f9056cf620dfb2c6bc617f74292dcf2f4fd6c2ed6416e4e0a9080109940943c4
MD5 2c3286b7cd41cfe553debbecd2f93442
BLAKE2b-256 3d71298d2b9d2e9cad9e1d02bc59273828b6ab2d4a7cad8b08c8a37b59b5aa04

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mocking_utils-1.2.1-py2-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.7.1 requests/2.26.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/2.7.16

File hashes

Hashes for mocking_utils-1.2.1-py2-none-any.whl
Algorithm Hash digest
SHA256 62b9a72fda0d73b039c37dcec02b51dc8fa732dfcc5b482e5921b4b9cd835f59
MD5 d8558c766d702a6c6fbe00e4c7868ec0
BLAKE2b-256 606d5ae68f9b8cecc0025ba41b3d51ccbc79dd8ee63f9529230fa2e799597e12

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