pMock has not been under active development since mid 2004.

For other suitable mocking frameworks see the Cheescake info on python mock testing tools

# pMock

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:

- Mock objects are created with expectations and simple behaviours
- Code under test is called with the mock objects
- Code state is asserted as in normal unit tests
- The mock objects' expectations are verified (basically another assertion)

See the overview for an introduction on how to use pMock in your unit tests.

## Requirements

- pMock is currently written for versions of Python >= 2.3
- pMock is licensed under the same terms as Python

- Overview of API

## Development

Bitbucket project page

Author: Graham Carlyle (grahamcarlyle at graham carlyle dot com)