Skip to main content

Mocking library for Python inspired by Google Mock C++ mocking toolkit

Project description

PyPI - License PyPI PyPI - Downloads codecov


Highly customizable and expressive mocking library for Python.


Mockify is a library inspired by Google Mock C++ framework, but adopted to Python world.

Mockify is based on expectations that you need to record on your mocks before those are called by code you're testing. And expectations you're recording are basically assertions that must pass before test ends. Along with expectations you can also record actions the mock will execute once called. And all of these is provided by simple, expressive and easy to use API.

Here's a simple example:

from mockify.core import satisfied
from mockify.mock import Mock
from mockify.actions import Return

def func_caller(func):
    return func()

def test_func_caller():
    func_mock = Mock('greet')
    func_mock.expect_call().will_once(Return('Hello, world!'))
    with satisfied(func_mock):
        assert func_caller(func_mock) == 'Hello, world!'

Mockify allows you to:

  • Record expectations with any number of positional and/or keyword arguments,
  • Set expected call count or call count range,
  • Record action chains, allowing subsequent action can be performed on subsequent call to same mock,
  • Record repeated actions that can be executed any number of times,
  • Use matchers, allowing to match range of parameters the mock is called with instead of exact ones,
  • and more.

I hope you'll find this library useful.


Newest documentation can be found at


Source code is available at


This software is released under the terms of the MIT license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mockify, version 0.13.1
Filename, size File type Python version Upload date Hashes
Filename, size mockify-0.13.1-py3-none-any.whl (49.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size mockify-0.13.1.tar.gz (90.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page