Skip to content

Commit c65c780

Browse files
authored
Add two more tests exercising the adapter (#6936)
Closes #6935
1 parent 579cd9f commit c65c780

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_requests.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,32 @@ def test_session_get_adapter_prefix_matching_is_case_insensitive(self):
16631663

16641664
assert s.get_adapter(url_matching_prefix_with_different_case) is my_adapter
16651665

1666+
def test_session_get_adapter_prefix_with_trailing_slash(self):
1667+
# from issue #6935
1668+
prefix = "https://example.com/" # trailing slash
1669+
url_matching_prefix = "https://example.com/some/path"
1670+
url_not_matching_prefix = "https://example.com.other.com/some/path"
1671+
1672+
s = requests.Session()
1673+
adapter = HTTPAdapter()
1674+
s.mount(prefix, adapter)
1675+
1676+
assert s.get_adapter(url_matching_prefix) is adapter
1677+
assert s.get_adapter(url_not_matching_prefix) is not adapter
1678+
1679+
def test_session_get_adapter_prefix_without_trailing_slash(self):
1680+
# from issue #6935
1681+
prefix = "https://example.com" # no trailing slash
1682+
url_matching_prefix = "https://example.com/some/path"
1683+
url_extended_hostname = "https://example.com.other.com/some/path"
1684+
1685+
s = requests.Session()
1686+
adapter = HTTPAdapter()
1687+
s.mount(prefix, adapter)
1688+
1689+
assert s.get_adapter(url_matching_prefix) is adapter
1690+
assert s.get_adapter(url_extended_hostname) is adapter
1691+
16661692
def test_header_remove_is_case_insensitive(self, httpbin):
16671693
# From issue #1321
16681694
s = requests.Session()

0 commit comments

Comments
 (0)