Python decorators for mocking

This module contains a set of decorators that allow to mock functions. (Replacing the behavior of a method, attribute, object or class)

Requisites

This module has been created using python 3.4 and tested in python 2.7, 3.4 and 3,5. This should works in python 2.7 and higher. If you want to know if this module works in a concrete python version, download the project and execute:

make test PYTHON_VERSION=<python-version>

where <python-version> is the version to test. Note: you must be installed that version.

Change log:

1.0:

1.0.1:

1.0.2-1.0.4

1.0.5

1.0.6

1.0.7

1.0.9

Installation

This module can be installed using the following options:

Usage

The tests contain examples to use this library but here there are the more useful examples:

FunctionMock

This mock replace a function for other. Example

The parameters are the following:

FunctionMockResult

This mock replace a function for a result value. Example

The parameters are the following:

FunctionMockChangeResult

This mock modify the result of a function. i.e. if Add 2 to a result of a function. Example

The parameters are the following:

FunctionMockCheckCall

This mock modify the result of a function. i.e. if Add 2 to a result of a function. Example

The parameters are the following:

AttributeMock

This mock change the value of a attribute for other. Example

The parameters are the following:

ClassMock

This mock only work in python 3 and higher. This mock replace a class or object by other. Example

The parameters are the following:

DictMock

This mock replace a value in a map by other value. Example

The parameters are the following: