Skip to content

Commit 305215d

Browse files
committed
test: add test_use_UnixAdapter_directly
This new test tests using the `UnixAdapter` directly, like [httpie-unixsocket](https://github.com/httpie/httpie-unixsocket) does. I wrote this test because I found a case, on the `pluggable-urlparse` branch, where tests were passing, but executing: ``` http http+unix://%2Fvar%2Frun%2Fdocker.sock/info ``` was failing.
1 parent f5965d8 commit 305215d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

requests_unixsocket/tests/test_requests_unixsocket.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ def get_sock_prefix(path):
4747
)
4848

4949

50+
def test_use_UnixAdapter_directly():
51+
"""Test using UnixAdapter directly, because
52+
https://github.com/httpie/httpie-unixsocket does this
53+
"""
54+
with UnixSocketServerThread() as usock_thread:
55+
adapter = UnixAdapter()
56+
request = requests.Request(
57+
method='GET',
58+
url='http+unix://%2Fvar%2Frun%2Fdocker.sock/info',
59+
)
60+
url = adapter.request_url(request=request, proxies=None)
61+
assert url == '/info'
62+
63+
5064
def test_unix_domain_adapter_ok():
5165
with UnixSocketServerThread() as usock_thread:
5266
session = Session('http+unix://')

0 commit comments

Comments
 (0)