1. Szczepan Faber
  2. mockito-python

Source

mockito-python /

Filename Size Date modified Message
mockito
mockito_test
mockito_util
70 B
188 B
385 B
428 B
403 B
1.1 KB
1.3 KB
14.9 KB
128 B
1.1 KB
171 B
266 B

Mockito is a spying framework based on Java library with the same name.

  1. To install:
$ python setup.py install
  1. To run all tests:
$ python setup.py test
  1. For more info, see:

http://code.google.com/p/mockito-python/

Feel free to contribute more documentation or feedback!

  1. Our user and developer discussion group is:
http://groups.google.com/group/mockito-python
  1. Mockito is licensed under the MIT license
  2. Library was tested with the following Python versions:
Python 2.4.5 Python 2.5.4 Python 2.6.1 Python 3.1.1
  1. (Generated from mockito_demo_test.py) Basic usage:

import unittest from mockito import mock, when, verify

class DemoTest(unittest.TestCase):
def testStubbing(self):

# create a mock ourMock = mock()

# stub it when(ourMock).getStuff("cool").thenReturn("cool stuff")

# use the mock self.assertEqual("cool stuff", ourMock.getStuff("cool"))

# what happens when you pass different argument? self.assertEqual(None, ourMock.getStuff("different argument"))

def testVerification(self):

# create a mock theMock = mock()

# use the mock theMock.doStuff("cool")

# verify the interactions. Method and parameters must match. Otherwise verification error. verify(theMock).doStuff("cool")