Spying framework
Project description
Mockito is a spying framework originally based on the Java library with the same name. (Actually we invented the strict stubbing mode back in 2009.)
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
Development
I use rye, and if you do too: you just clone this repo to your computer, then run rye sync in the root directory. Finally, activate the virtualenv. (rye shell gives you a hint on how to do that.)
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mockito-1.5.3.tar.gz
(58.7 kB
view details)
Built Distribution
mockito-1.5.3-py3-none-any.whl
(30.2 kB
view details)
File details
Details for the file mockito-1.5.3.tar.gz
.
File metadata
- Download URL: mockito-1.5.3.tar.gz
- Upload date:
- Size: 58.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7192840e7d70ec24639cc5e18efee5d418c83ad86c0fd2bf7e71c3e42ae0aa7 |
|
MD5 | e66a5f1179bcd90e870ca177e59b2a2c |
|
BLAKE2b-256 | 288488ee894d53d805e246a2bdb76110644999793ecd9a004ed5e9dd777b9899 |
File details
Details for the file mockito-1.5.3-py3-none-any.whl
.
File metadata
- Download URL: mockito-1.5.3-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 094a5e7ebd140e6b5dcb0fc581f83616000f2b1311facc3b5e6167b906b52955 |
|
MD5 | d6a3314c02a0f2730215d5bd2190e182 |
|
BLAKE2b-256 | bd02992b22a48ca26cf11afe368f47af106d34634926dc74b2556082d102fb36 |