(mock)
| 255 | |
| 256 | |
| 257 | def _setup_async_mock(mock): |
| 258 | mock._is_coroutine = asyncio.coroutines._is_coroutine |
| 259 | mock.await_count = 0 |
| 260 | mock.await_args = None |
| 261 | mock.await_args_list = _CallList() |
| 262 | |
| 263 | # Mock is not configured yet so the attributes are set |
| 264 | # to a function and then the corresponding mock helper function |
| 265 | # is called when the helper is accessed similar to _setup_func. |
| 266 | def wrapper(attr, /, *args, **kwargs): |
| 267 | return getattr(mock.mock, attr)(*args, **kwargs) |
| 268 | |
| 269 | for attribute in ('assert_awaited', |
| 270 | 'assert_awaited_once', |
| 271 | 'assert_awaited_with', |
| 272 | 'assert_awaited_once_with', |
| 273 | 'assert_any_await', |
| 274 | 'assert_has_awaits', |
| 275 | 'assert_not_awaited'): |
| 276 | |
| 277 | # setattr(mock, attribute, wrapper) causes late binding |
| 278 | # hence attribute will always be the last value in the loop |
| 279 | # Use partial(wrapper, attribute) to ensure the attribute is bound |
| 280 | # correctly. |
| 281 | setattr(mock, attribute, partial(wrapper, attribute)) |
| 282 | |
| 283 | |
| 284 | def _is_magic(name): |
no test coverage detected