Skip to main content

Mocking library for Python.

None

Project description

mimid

Build Status Coverage Status License Version Python versions Code style: black

Mocking library for Python.

⚠️ This project is under development, current version is just a PoC.

Installation

To install mimid, simply use pip:

$ pip install mimid

Quick start

from mimid import mock, every, verify

class Calc:
    def add(self, a, b):
        return a + b

def test_add():
    calc_mock = mock(Calc)
    every(calc_mock.add).returns(5)    

    result = calc_mock.add(2, 2)

    assert result == 5
    verify(calc_mock.add).with_args(2, 2).called_once()

Why not unittest.mock?

Python built-in mock module is an awesome tool. It's a first choice if you want to mock something in you tests.

However it has a few disadvantages:

  • it doesn't work well with modern IDEs (e.g. auto completion)
  • it doesn't work well with type hinted code
  • it's difficult to define different behaviours for different call arguments
  • it allows too much freedom

Authors

Created by Konrad Hałas.

Project details

None

Download files

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

Source Distribution

mimid-0.0.2.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

mimid-0.0.2-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

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