Highly useful utilities for mocking execution flow during unit test execution.
Project description
mocking-utils
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.2.tar.gz
(5.1 kB
view details)
Built Distribution
File details
Details for the file mocking-utils-1.1.2.tar.gz
.
File metadata
- Download URL: mocking-utils-1.1.2.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.0 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc16acfb50b90a680f7e11fe03c68e5de373861bc5a6549e20ead7b9e87a1d33 |
|
MD5 | 880ac88b505cf9aa045f50dd7b963412 |
|
BLAKE2b-256 | 2b95bc9c37a27784c9e19fec1af654eaa59219de79cd894368a4d7b59ada0230 |
File details
Details for the file mocking_utils-1.1.2-py2-none-any.whl
.
File metadata
- Download URL: mocking_utils-1.1.2-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.0 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d11e2936f6440366f7c9fd33db712cf92ec97dfc71703dc9939c9605a1d960ce |
|
MD5 | 7d75e22a2066f949ca26df3a67622dfc |
|
BLAKE2b-256 | 5f090f00372b5bffeddc40c05b7a23b5e5c4947a09d1a659754b3fc9c4b799a5 |