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.
(self, /, *args, **kwargs)
| 965 | raise AssertionError(msg) |
| 966 | |
| 967 | def assert_called_with(self, /, *args, **kwargs): |
| 968 | """assert that the last call was made with the specified arguments. |
| 969 | |
| 970 | Raises an AssertionError if the args and keyword args passed in are |
| 971 | different to the last call to the mock.""" |
| 972 | if self.call_args is None: |
| 973 | expected = self._format_mock_call_signature(args, kwargs) |
| 974 | actual = 'not called.' |
| 975 | error_message = ('expected call not found.\nExpected: %s\n Actual: %s' |
| 976 | % (expected, actual)) |
| 977 | raise AssertionError(error_message) |
| 978 | |
| 979 | def _error_message(): |
| 980 | msg = self._format_mock_failure_message(args, kwargs) |
| 981 | return msg |
| 982 | expected = self._call_matcher(_Call((args, kwargs), two=True)) |
| 983 | actual = self._call_matcher(self.call_args) |
| 984 | if actual != expected: |
| 985 | cause = expected if isinstance(expected, Exception) else None |
| 986 | raise AssertionError(_error_message()) from cause |
| 987 | |
| 988 | |
| 989 | def assert_called_once_with(self, /, *args, **kwargs): |