()
| 74 | fallback_loop: list[asyncio.AbstractEventLoop] = [] |
| 75 | |
| 76 | def _resolve_loop() -> asyncio.AbstractEventLoop: |
| 77 | # MockClientResponse is normally built inside aiohttp's running loop, so |
| 78 | # prefer that. In a sync context there is no running loop; avoid |
| 79 | # asyncio.get_event_loop(), which on 3.12+ emits a DeprecationWarning |
| 80 | # (and can RuntimeError) when no current loop is set. Use one cached |
| 81 | # loop instead -- the mock only stores it and calls loop.get_debug(). |
| 82 | try: |
| 83 | return asyncio.get_running_loop() |
| 84 | except RuntimeError: |
| 85 | if not fallback_loop: |
| 86 | fallback_loop.append(asyncio.new_event_loop()) |
| 87 | return fallback_loop[0] |
| 88 | |
| 89 | def _mock_client_response_init( |
| 90 | self: Any, method: str, url: Any, request_info: Any = None |
no test coverage detected