Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def assert_called_once(mock, expected_args=None, expected_kwargs=None):
- """Assert ``mock`` called once with expected args/kwargs.
- :param mock.Mock mock: The Mock to assert against.
- :param expected_args:
- A tuple containing the expected positional arguments.
- :param expected_kwargs:
- A dictionary containing the expected keyword arguments.
- """
- assert_true(isinstance(mock, Mock))
- if expected_args is None:
- expected_args = ()
- if expected_kwargs is None:
- expected_kwargs = {}
- assert_equal(1, mock.call_count)
- args, kwargs = mock.call_args
- assert_equal(expected_args, args)
- assert_equal(expected_kwargs, kwargs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement