pMock is a Python module for testing Python code using mock objects.
...
import pmock
...
class InstrumentTest(unittest.TestCase):
def test_low_quality_analysis(self):
analyser_mock = pmock.Mock()
analyser_mock.expects().analyse(pmock.eq("123")).will(pmock.return_value("30"))
instrument = Instrument(analyser_mock)
instrument.insert("sample#123")
self.assert_(instrument.is_low_quality_indicator_on())
analyser_mock.verify()
...
Inspired by the Java jMock library, pMock makes the writing of unit tests using mock object techniques easier.
The typical sequence of steps in a test involving pMock mock objects are:Sourceforge project page
Browse the source in CVS
Author: Graham Carlyle (grahamcarlyle at users dot sourceforge dot net)