Assert it is possible to define a custom key function.
(self)
| 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.""" |
nothing calls this directly
no test coverage detected