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.3.tar.gz
(5.1 kB
view details)
Built Distribution
File details
Details for the file mocking-utils-1.1.3.tar.gz
.
File metadata
- Download URL: mocking-utils-1.1.3.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 | f97736a71c2bc267dbd1c2f8290089641c2daf7f50e88ae3d7624013962afac5 |
|
MD5 | c0c0d31bbb339220ff64984217a3b34f |
|
BLAKE2b-256 | 9862fde4cbb175cb0c82a1144ef3544d133b48fa0e5f8a8a2d59266436d3530b |
File details
Details for the file mocking_utils-1.1.3-py2-none-any.whl
.
File metadata
- Download URL: mocking_utils-1.1.3-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 | c5e85ae905d0eaa2f3ffbda6e2c4d0898df688585747750d861c1af347568429 |
|
MD5 | a5a8fa92995f3eb89ebc1a28ffafd0cf |
|
BLAKE2b-256 | 12ba66540c5e40075e16b65347f437c00674a75305886d68f2f1de0a58445cdf |