Spying framework
Project description
Mockito is a spying framework originally based on the Java library with the same name.
Install
pip install mockito
Walk-through
Say you want to mock the class Dog:
class Dog(object): def bark(self, sound): return "%s!" % sound
To get you started:
from mockito import * # mock the class when(Dog).bark('Wuff').thenReturn('Miau!') # instantiate rex = Dog() assert rex.bark('Wuff') == 'Miau!' unstub()
You can also start with an empty stub:
obj = mock() # pass it around, eventually it will be used obj.say('Hi') # verify interactions verify(obj).say('Hi') verifyNoMoreInteractions(obj)
Currently you can find some more docs at http://code.google.com/p/mockito-python/
Feel free to contribute more documentation or feedback!
To run all tests:
pip install nose nosetests
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 Distributions
mockito-0.6.0.zip
(36.2 kB
view details)
mockito-0.6.0.tar.gz
(15.7 kB
view details)
File details
Details for the file mockito-0.6.0.zip
.
File metadata
- Download URL: mockito-0.6.0.zip
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c2a12d3140519bdbe5e17846dc0dd25cc899bff5e7da7d34ea22a90e808b36a |
|
MD5 | 47ae7d38b211cd4092d6149d022edd67 |
|
BLAKE2b-256 | f7acdc36b1b79230a72d85f0aefeada60ab6bc3a3a503a38f4e6d597d9286011 |
File details
Details for the file mockito-0.6.0.tar.gz
.
File metadata
- Download URL: mockito-0.6.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c84be7d1f5cc9be943d3f5cc2ce4d07d515cb6aa6d2e9bb95ce4683b764222de |
|
MD5 | cd6439692553c9fd0f1b0a5ffe255450 |
|
BLAKE2b-256 | be542e5269f8db295a7c931cecb5ba7a370dec0d0a46fdfe934e3bb806b01190 |