Skip to content
Myr

Add test for Session.get_adapter() prefix matching

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Alvaro Gutierrez Perez · committed by Alvaro Gutierrez Perez · parent af88af6 · Browse files · 1 file+18 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+18 added−0 removed

  • tests:+18 added−0 removed

1 file+18 added−0 removed

modified:tests/test_requests.py+18 added
1349 unmodified lines
1350 s2.mount('https://', HTTPAdapter())1351 assert 'http://' in s2.adapters1352 assert 'https://' in s2.adapters13531354 def test_session_get_adapter_prefix_matching(self, httpbin):1355 prefix = 'https://example.com'1356 more_specific_prefix = prefix + '/some/path'13571358 url_matching_only_prefix = prefix + '/another/path'1359 url_matching_more_specific_prefix = more_specific_prefix + '/longer/path'1360 url_not_matching_prefix = 'https://another.example.com/'13611362 s = requests.Session()1363 prefix_adapter = HTTPAdapter()1364 more_specific_prefix_adapter = HTTPAdapter()1365 s.mount(prefix, prefix_adapter)1366 s.mount(more_specific_prefix, more_specific_prefix_adapter)13671368 assert s.get_adapter(url_matching_only_prefix) is prefix_adapter1369 assert s.get_adapter(url_matching_more_specific_prefix) is more_specific_prefix_adapter1370 assert s.get_adapter(url_not_matching_prefix) not in (prefix_adapter, more_specific_prefix_adapter)13711372 def test_session_get_adapter_prefix_matching_is_case_insensitive(self, httpbin):1373 mixed_case_prefix = 'hTtPs://eXamPle.CoM/MixEd_CAse_PREfix'1374 url_matching_prefix = mixed_case_prefix + '/full_url'1375 url_matching_prefix_with_different_case = 'HtTpS://exaMPLe.cOm/MiXeD_caSE_preFIX/another_url'
1044 unmodified lines