MCPcopy Index your code
hub / github.com/RustPython/RustPython / assert_awaited_with

Method assert_awaited_with

Lib/unittest/mock.py:2371–2387  ·  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

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

Calls 4

_CallClass · 0.85
isinstanceFunction · 0.85
_call_matcherMethod · 0.80

Tested by 5

test_create_autospecMethod · 0.64
test_asyncMethod · 0.64