Navigation

Project Links

Meta

Maintainers

Funk is a mocking framework for Python, influenced heavily by JMock.
Funk helps to test modules in isolation by allowing mock objects to be used in place of “real” objects.
Funk is licensed under the 2-clause BSD licence.

Installation

$ pip install funk

Example

Let’s say we have a TagRepository class,
which has a fetch_all method on it.
This method will fetch all instances of Tag from the database for us.

We also have a class that we’d like to test, called TagDisplayer.
Its constructor takes a TagRepository,
and has a method display_all.
We want to test that this method will grab all of the tags from the repository,
sort them into alphabetical order,
and write their names into a string separated by new lines.