mockify.exc - Library exceptions

exception mockify.exc.OversaturatedCall(expectation, call)

Bases: TypeError

Raised when mock is called more times than expected.

This exception will be thrown only if mock has actions defined as it does not know what to do next if all expected actions were already executed.

Parameters:
  • expectation – Instance of mockify.engine.Expectation class representing expectation that was oversaturated
  • call – Instance of mockify.engine.Call class representing mock call that oversaturated expectation
call

Instance of mockify.engine.Call passed to OversaturatedCall constructor.

expectation

Instance of mockify.engine.Expectation passed to OversaturatedCall constructor.

exception mockify.exc.UninterestedCall(call)

Bases: TypeError

Raised when uninterested mock is called.

Mockify requires each mock call to have matching expectation recorded. If none is found during call, then this exception is raised, terminating the test.

Parameters:call – Instance of mockify.engine.Call class representing uinterested mock call
call

Instance of mockify.engine.Call passed to UninterestedCall constructor.

exception mockify.exc.UninterestedGetterCall(name)

Bases: mockify.exc.UninterestedPropertyAccess

Raised when uninterested property getter is called.

This will be raised if some system under test gets mock property that has no expectations set.

New in version 0.3.

exception mockify.exc.UninterestedPropertyAccess(name)

Bases: TypeError

Base class for exceptions signalling uninterested property access.

This situation occurs when object property is accessed without previous matching expectation being recorded.

New in version 0.3.

Parameters:name – Property name
name

Name of property being accessed.

exception mockify.exc.UninterestedSetterCall(name, value)

Bases: mockify.exc.UninterestedPropertyAccess

Raised when uninterested property setter is called.

This will be raised if some system under test sets mock property that has no matching expectations set.

New in version 0.3.

value

Value property was set to.

exception mockify.exc.Unsatisfied(expectations)

Bases: AssertionError

Raised by mockify.engine.Registry.assert_satisfied() method when there is at least one unsatisfied expectation.

This exception displays explanatory information to the user:

  • file location where unsatisfied expectation was recorded
  • expected call pattern
  • expected call count
  • actual call count
  • next action to be executed (if any)
Parameters:expectations – List of mockify.engine.Expectation instances representing all unsatisfied expectations
expectations

Instance of mockify.engine.Expectation passed to Unsatisfied constructor.