MCPcopy Index your code
hub / github.com/python/cpython / assert_awaited_with

Method assert_awaited_with

Lib/unittest/mock.py:2378–2394  ·  view source on GitHub ↗

Assert that the last await was with the specified arguments.

(self, /, *args, **kwargs)

Source from the content-addressed store, hash-verified

2376 raise AssertionError(msg)
2377
2378 def assert_awaited_with(self, /, *args, **kwargs):
2379 """
2380 Assert that the last await was with the specified arguments.
2381 """
2382 if self.await_args is None:
2383 expected = self._format_mock_call_signature(args, kwargs)
2384 raise AssertionError(f'Expected await: {expected}\nNot awaited')
2385
2386 def _error_message():
2387 msg = self._format_mock_failure_message(args, kwargs, action='await')
2388 return msg
2389
2390 expected = self._call_matcher(_Call((args, kwargs), two=True))
2391 actual = self._call_matcher(self.await_args)
2392 if actual != expected:
2393 cause = expected if isinstance(expected, Exception) else None
2394 raise AssertionError(_error_message()) from cause
2395
2396 def assert_awaited_once_with(self, /, *args, **kwargs):
2397 """

Calls 3

_CallClass · 0.85
_call_matcherMethod · 0.80

Tested by 5

test_create_autospecMethod · 0.64
test_asyncMethod · 0.64