MCPcopy
hub / github.com/urllib3/urllib3 / test_custom_pool_key

Method test_custom_pool_key

test/test_poolmanager.py:312–329  ·  view source on GitHub ↗

Assert it is possible to define a custom key function.

(self)

Source from the content-addressed store, hash-verified

310 }
311
312 def test_custom_pool_key(self) -> None:
313 """Assert it is possible to define a custom key function."""
314 p = PoolManager(10)
315
316 p.key_fn_by_scheme["http"] = lambda x: tuple(x["key"]) # type: ignore[assignment]
317 pool1 = p.connection_from_url(
318 "http://example.com", pool_kwargs={"key": "value"}
319 )
320 pool2 = p.connection_from_url(
321 "http://example.com", pool_kwargs={"key": "other"}
322 )
323 pool3 = p.connection_from_url(
324 "http://example.com", pool_kwargs={"key": "value", "x": "y"}
325 )
326
327 assert 2 == len(p.pools)
328 assert pool1 is pool3
329 assert pool1 is not pool2
330
331 def test_override_pool_kwargs_url(self) -> None:
332 """Assert overriding pool kwargs works with connection_from_url."""

Callers

nothing calls this directly

Calls 2

connection_from_urlMethod · 0.95
PoolManagerClass · 0.90

Tested by

no test coverage detected