Skip to main content

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

Project description

Mockify

Highly customizable and expressive mocking library for Python.

About

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 import satisfied
from mockify.mock import Mock
from mockify.actions import Return

greet = Mock('greet')
greet.expect_call().will_once(Return('Hello, world!'))

with satisfied(greet):
    assert greet() == '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.

Documentation

Newest documentation can be found at https://mockify.readthedocs.org/.

Source

Source code is available at https://gitlab.com/zef1r/mockify/.

License

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.

Source Distribution

mockify-0.7.1.tar.gz (60.1 kB view details)

Uploaded Source

Built Distribution

mockify-0.7.1-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file mockify-0.7.1.tar.gz.

File metadata

  • Download URL: mockify-0.7.1.tar.gz
  • Upload date:
  • Size: 60.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for mockify-0.7.1.tar.gz
Algorithm Hash digest
SHA256 e0c437cbee157d284e3ab287ba7b5c988b1548888512f1feb65dc0182c713b10
MD5 2da7d19bac8c4129e8afad23afde524a
BLAKE2b-256 4b16a1a0d6c2b079fe4ba2b7501e677828a5fae5f218effb882ec4c6ea7f3b26

See more details on using hashes here.

Provenance

File details

Details for the file mockify-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: mockify-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for mockify-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 527c40201495fe61ab75a745ae353693d90c57931cce210aa1acdab5a33dbc03
MD5 a520bcab3823c3cfcc369f4512016734
BLAKE2b-256 cdff751ae3207adf995d7aa58775cbfb8fd56666b4df6c31c1e28f32c06a13d7

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page