(mock)
| 281 | |
| 282 | |
| 283 | def _setup_async_mock(mock): |
| 284 | mock._is_coroutine = asyncio.coroutines._is_coroutine |
| 285 | mock.await_count = 0 |
| 286 | mock.await_args = None |
| 287 | mock.await_args_list = _CallList() |
| 288 | |
| 289 | # Mock is not configured yet so the attributes are set |
| 290 | # to a function and then the corresponding mock helper function |
| 291 | # is called when the helper is accessed similar to _setup_func. |
| 292 | def wrapper(attr, /, *args, **kwargs): |
| 293 | return getattr(mock.mock, attr)(*args, **kwargs) |
| 294 | |
| 295 | for attribute in ('assert_awaited', |
| 296 | 'assert_awaited_once', |
| 297 | 'assert_awaited_with', |
| 298 | 'assert_awaited_once_with', |
| 299 | 'assert_any_await', |
| 300 | 'assert_has_awaits', |
| 301 | 'assert_not_awaited'): |
| 302 | |
| 303 | # setattr(mock, attribute, wrapper) causes late binding |
| 304 | # hence attribute will always be the last value in the loop |
| 305 | # Use partial(wrapper, attribute) to ensure the attribute is bound |
| 306 | # correctly. |
| 307 | setattr(mock, attribute, partial(wrapper, attribute)) |
| 308 | |
| 309 | |
| 310 | def _is_magic(name): |
no test coverage detected
searching dependent graphs…