Mocking library for Python.
Project description
mimid
Mocking library for Python.
⚠️ This project is under heavy development, API could be unstable.
Installation
To install mimid
, simply use pip
:
$ pip install mimid
Quick start
from mimid import mock, every, verify
def add(a: int, b: int) -> int:
return a + b
def test_add():
add_mock = mock(add)
every(add_mock).returns(5)
result = add_mock(2, 2)
assert result == 5
verify(add_mock).with_args(2, 2).called(times=1)
Features
Mimid supports following features:
- easy mock behaviour configuration and verification
- works with classes and plain functions
- it's fully type hinted - it works with IDE's and type checkers
- it has clean API, without too much magic
Why not 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) and type checkers
- it's difficult to define different behaviours for different cases
- it allows too much freedom, you can do anything with your mock object, even if you didn't define any expectations
Inspiration
Mimid is highly inspired by mocking frameworks from a JVM world, like mockito or mockk.
Authors
Created by Konrad Hałas.
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
mimid-0.0.5.tar.gz
(3.4 kB
view hashes)
Built Distribution
mimid-0.0.5-py3-none-any.whl
(4.2 kB
view hashes)