(self, *, ready, cancel, **conn_args)
| 2143 | self.loop.set_exception_handler(old_handler) |
| 2144 | |
| 2145 | async def _test_connect_interruption(self, *, ready, cancel, **conn_args): |
| 2146 | async def connect(): |
| 2147 | # Python 3.9 wraps CancelledError when it crosses a task boundary. |
| 2148 | # Capture the original exception so its cause can be checked. |
| 2149 | expected = (asyncio.CancelledError if cancel |
| 2150 | else asyncio.TimeoutError) |
| 2151 | with self.assertRaises(expected) as raised: |
| 2152 | await self.connect(timeout=2 if cancel else 0.2, **conn_args) |
| 2153 | return raised.exception |
| 2154 | |
| 2155 | task = self.loop.create_task(connect()) |
| 2156 | try: |
| 2157 | if cancel: |
| 2158 | await asyncio.wait_for(ready.wait(), 2) |
| 2159 | task.cancel() |
| 2160 | return await task |
| 2161 | finally: |
| 2162 | if not task.done(): |
| 2163 | task.cancel() |
| 2164 | await asyncio.gather(task, return_exceptions=True) |
| 2165 | |
| 2166 | @contextlib.asynccontextmanager |
| 2167 | async def connection_proxy(self, *faults, direct=False): |
no test coverage detected