MCPcopy
hub / github.com/urllib3/urllib3 / test_contextmanager

Method test_contextmanager

test/test_connectionpool.py:434–454  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

432 HTTPConnectionPool(None) # type: ignore[arg-type]
433
434 def test_contextmanager(self) -> None:
435 with connection_from_url("http://google.com:80") as pool:
436 # Populate with some connections
437 conn1 = pool._get_conn()
438 conn2 = pool._get_conn()
439 conn3 = pool._get_conn()
440 pool._put_conn(conn1)
441 pool._put_conn(conn2)
442
443 old_pool_queue = pool.pool
444
445 assert pool.pool is None
446 with pytest.raises(ClosedPoolError):
447 pool._get_conn()
448
449 pool._put_conn(conn3)
450 with pytest.raises(ClosedPoolError):
451 pool._get_conn()
452 with pytest.raises(Empty):
453 assert old_pool_queue is not None
454 old_pool_queue.get(block=False)
455
456 def test_url_from_pool(self) -> None:
457 with connection_from_url("http://google.com:80") as pool:

Callers

nothing calls this directly

Calls 4

connection_from_urlFunction · 0.90
_get_connMethod · 0.80
_put_connMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected