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

Method assert_awaited_once_with

Lib/unittest/mock.py:2396–2405  ·  view source on GitHub ↗

Assert that the mock was awaited exactly once and with the specified arguments.

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

Source from the content-addressed store, hash-verified

2394 raise AssertionError(_error_message()) from cause
2395
2396 def assert_awaited_once_with(self, /, *args, **kwargs):
2397 """
2398 Assert that the mock was awaited exactly once and with the specified
2399 arguments.
2400 """
2401 if not self.await_count == 1:
2402 msg = (f"Expected {self._mock_name or 'mock'} to have been awaited once."
2403 f" Awaited {self.await_count} times.")
2404 raise AssertionError(msg)
2405 return self.assert_awaited_with(*args, **kwargs)
2406
2407 def assert_any_await(self, /, *args, **kwargs):
2408 """

Callers 4

test_create_autospecMethod · 0.80
test_asyncMethod · 0.80

Calls 1

assert_awaited_withMethod · 0.95

Tested by 4

test_create_autospecMethod · 0.64
test_asyncMethod · 0.64