mockify.actions - Classes for recording side effects

Module containing predefined actions that can be used as argument for Expectation.will_once() or Expectation.will_repeatedly().

Basically, any class containing following methods is considered an action:


Returning string representation of an action.

This is used for error reporting.

__call__(self, *args, **kwargs)

Method that is called when mock is called.

Entire action logic goes in here.

class mockify.actions.Invoke(func)

Bases: object

Makes mock invoking given function when called.

When mock is called, all arguments (if there are any) are passed to the func and its return value is returned as mock’s return value.

Parameters:func – Function to be executed
class mockify.actions.Raise(exc)

Bases: object

Makes mock raising given exception when called.

Parameters:exc – Instance of exception to be raised
class mockify.actions.Return(value)

Bases: object

Makes mock returning given value when called.

Parameters:value – Value to be returned