Spying framework
Project description
Mockito is a spying framework originally based on the Java library with the same name.
Install
pip install mockito
Run the tests
pip install nose nosetests
Quick Start
Start with an empty stub:
from mockito import *
obj = mock()
# pass it around, eventually it will be used
obj.say('Hi')
# back in the tests, verify interactions
verify(obj).say('Hi')
verifyNoMoreInteractions(obj)
Or, say you want to mock the class Dog:
class Dog(object):
def bark(self, sound):
return "%s!" % sound
# mock the class
when(Dog).bark('Wuff').thenReturn('Miau!')
# instantiate
rex = Dog()
assert rex.bark('Wuff') == 'Miau!'
unstub()
Read the docs
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-0.6.1.tar.gz
(15.1 kB
view details)
File details
Details for the file mockito-0.6.1.tar.gz.
File metadata
- Download URL: mockito-0.6.1.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5379629b6d208d1c4c9f8b8e99b9acb27d7ef67a08b0c01927aa78a18f5b0f9d
|
|
| MD5 |
5a853315507368bf28b30093217b4a21
|
|
| BLAKE2b-256 |
95b701202bce3564329056a76f1fab437bfe38a1f77965ab1f46404aedc0a3df
|