MCPcopy
hub / github.com/psf/requests / test_session_get_adapter_prefix_matching

Method test_session_get_adapter_prefix_matching

tests/test_requests.py:1659–1681  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1657 assert "https://" in s2.adapters
1658
1659 def test_session_get_adapter_prefix_matching(self):
1660 prefix = "https://example.com"
1661 more_specific_prefix = prefix + "/some/path"
1662
1663 url_matching_only_prefix = prefix + "/another/path"
1664 url_matching_more_specific_prefix = more_specific_prefix + "/longer/path"
1665 url_not_matching_prefix = "https://another.example.com/"
1666
1667 s = requests.Session()
1668 prefix_adapter = HTTPAdapter()
1669 more_specific_prefix_adapter = HTTPAdapter()
1670 s.mount(prefix, prefix_adapter)
1671 s.mount(more_specific_prefix, more_specific_prefix_adapter)
1672
1673 assert s.get_adapter(url_matching_only_prefix) is prefix_adapter
1674 assert (
1675 s.get_adapter(url_matching_more_specific_prefix)
1676 is more_specific_prefix_adapter
1677 )
1678 assert s.get_adapter(url_not_matching_prefix) not in (
1679 prefix_adapter,
1680 more_specific_prefix_adapter,
1681 )
1682
1683 def test_session_get_adapter_prefix_matching_mixed_case(self):
1684 mixed_case_prefix = "hTtPs://eXamPle.CoM/MixEd_CAse_PREfix"

Callers

nothing calls this directly

Calls 3

mountMethod · 0.95
get_adapterMethod · 0.95
HTTPAdapterClass · 0.90

Tested by

no test coverage detected