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.
Metadata
Release files for mocking-utils 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mocking-utils-1.2.1.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mocking_utils-1.2.1-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 12.1 kB
Release files / mocking-utils-1.2.1.tar.gz
| Download URL | mocking-utils-1.2.1.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9056cf620dfb2c6bc617f74292dcf2f4fd6c2ed6416e4e0a9080109940943c4
|
|
BLAKE2b-256 checksum How to use checksums |
3d71298d2b9d2e9cad9e1d02bc59273828b6ab2d4a7cad8b08c8a37b59b5aa04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / mocking_utils-1.2.1-py2-none-any.whl
| Download URL | mocking_utils-1.2.1-py2-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
62b9a72fda0d73b039c37dcec02b51dc8fa732dfcc5b482e5921b4b9cd835f59
|
|
BLAKE2b-256 checksum How to use checksums |
606d5ae68f9b8cecc0025ba41b3d51ccbc79dd8ee63f9529230fa2e799597e12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|