API

mocksafe

The base mocksafe module.

mocksafe.plugin

This module provides an optional pytest plugin for mocksafe for monkeypatching.

mocksafe.mock(spec[, name])

Creates a mock of the given spec.

mocksafe.mock_module(module[, name])

Creates a mocked version of the given module.

mocksafe.mock_reset(mock_object)

Reset a mock object's configured stubbing and recorded calls.

mocksafe.when(mock_callable)

Stub a mocked method / Callable.

mocksafe.stub(mock_object)

Prepare to stub a property on mock_object.

mocksafe.that(mocked)

Used to assert how a mocked method was called.

mocksafe.spy(mocked)

This is used to capture the arguments that were passed when the given mocked was called, which is useful for making more detailed assertions on the contents.

mocksafe.MockProperty(return_value)

Used to mock a property on a mock object.

mocksafe.PropertyStubber(mock_object)

Used to set a MockProperty on an existing mock object.

mocksafe.WhenStubber(method_mock)

Set up conditions for when a stub is to be used.

mocksafe.MatchCallStubber(method_mock, matcher)

Set up results or side effects to be used when for the stub the condition matches.

mocksafe.LastCallStubber(method_mock)

Set up results or side effects to be used when for the stub the condition matches.

mocksafe.MockCalls(call_recorder)

Provides information about calls made to a mocked method.