Mockito is a spying framework originally based on the Java library with the same name.
Install
pip install mockito
Quick Start
90% use case is that you want to stub out a side effect.
from mockito import when, mock, unstub
when(os.path).exists('/foo').thenReturn(True)
# or:
import requests # the famous library
# you actually want to return a Response-like obj, we'll fake it
response = mock({'status_code': 200, 'text': 'Ok'})
when(requests).get(...).thenReturn(response)
# use it
requests.get('http://google.com/')
# clean up
unstub()
Read the docs
http://mockito-python.readthedocs.io/en/latest/
Run the tests
pip install pytest py.test
Metadata
Release files for mockito 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mockito-1.2.0.tar.gz | 23.5 kB | Details |
Release files / mockito-1.2.0.tar.gz
| Download URL | mockito-1.2.0.tar.gz |
|---|---|
| Size | 23.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a1cbae9d0aef4ae7586b03f2a463e8c5ba96aa937c0535ced4a5621f851feeb
|
|
BLAKE2b-256 checksum How to use checksums |
fb31ef441d0c362ba514c83106d50e015f54e06538be6273f4729bed69304fab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.8.0
|