MCPcopy
hub / github.com/aio-libs/aiohttp / test_connect_with_no_limits

Function test_connect_with_no_limits

tests/test_connector.py:3400–3429  ·  view source on GitHub ↗
(loop, key)

Source from the content-addressed store, hash-verified

3398
3399
3400async def test_connect_with_no_limits(loop, key) -> None:
3401 proto = mock.Mock()
3402 proto.is_connected.return_value = True
3403
3404 req = ClientRequest("GET", URL("http://localhost:80"), loop=loop)
3405
3406 conn = aiohttp.BaseConnector(loop=loop, limit=0, limit_per_host=0)
3407 conn._conns[key] = deque([(proto, loop.time())])
3408 conn._create_connection = mock.Mock()
3409 conn._create_connection.return_value = loop.create_future()
3410 conn._create_connection.return_value.set_result(proto)
3411
3412 acquired = False
3413 connection1 = await conn.connect(req, None, ClientTimeout())
3414
3415 async def f():
3416 nonlocal acquired
3417 connection2 = await conn.connect(req, None, ClientTimeout())
3418 acquired = True
3419 assert 1 == len(conn._acquired)
3420 assert not conn._acquired_per_host
3421 connection2.release()
3422
3423 task = loop.create_task(f())
3424
3425 await asyncio.sleep(0.01)
3426 assert acquired
3427 connection1.release()
3428 await task
3429 await conn.close()
3430
3431
3432async def test_connect_with_limit_cancelled(loop) -> None:

Callers

nothing calls this directly

Calls 6

connectMethod · 0.95
closeMethod · 0.95
ClientRequestClass · 0.90
ClientTimeoutClass · 0.90
fFunction · 0.70
releaseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…