tfds.testing.PickableDataSourceMock

Makes MagicMock pickable in order to work with multiprocessing in Grain.

call_args

call_args_list

call_count

called

mock_calls

return_value

side_effect

Methods

assert_any_call

assert the mock has been called with the specified arguments.

The assert passes if the mock has ever been called, unlike assert_called_with and assert_called_once_with that only pass if the call is the most recent one.

assert_called

assert that the mock was called at least once

assert_called_once

assert that the mock was called only once.

assert_called_once_with

assert that the mock was called exactly once and that that call was with the specified arguments.

assert_called_with

assert that the last call was made with the specified arguments.

Raises an AssertionError if the args and keyword args passed in are different to the last call to the mock.

assert_has_calls

assert the mock has been called with the specified calls. The mock_calls list is checked for the calls.

If any_order is False (the default) then the calls must be sequential. There can be extra calls before or after the specified calls.

If any_order is True then the calls can be in any order, but they must all appear in mock_calls.

assert_not_called

assert that the mock was never called.

attach_mock

Attach a mock as an attribute of this one, replacing its name and parent. Calls to the attached mock will be recorded in the method_calls and mock_calls attributes of this one.

configure_mock

Set attributes on the mock through keyword arguments.

Attributes plus return values and side effects can be set on child mocks using standard dot notation and unpacking a dictionary in the method call:

attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
mock.configure_mock(**attrs)

mock_add_spec

Add a spec to a mock. spec can either be an object or a list of strings. Only attributes on the spec can be fetched as attributes from the mock.

If spec_set is True then only attributes on the spec can be set.

reset_mock

Restore the mock object to its initial state.

__call__

Call self as a function.