<s> """<STR_LIT>""" <EOL> import logging <EOL> import pytest <EOL> import requests <EOL> import requests_unixsocket <EOL> from requests_unixsocket . testutils import UnixSocketServerThread <EOL> logger = logging . getLogger ( __name__ ) <EOL> def test_unix_domain_adapter_ok ( ) : <EOL> with UnixSocketServerThread ( ) as usock_thread : <EOL> session = requests_unixsocket . Session ( '<STR_LIT>' ) <EOL> urlencoded_usock = requests . compat . quote_plus ( usock_thread . usock ) <EOL> url = '<STR_LIT>' % urlencoded_usock <EOL> for method in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] : <EOL> logger . debug ( '<STR_LIT>' , method , url ) <EOL> r = getattr ( session , method ) ( url ) <EOL> logger . debug ( <EOL> '<STR_LIT>' , <EOL> r , r . text , r . headers ) <EOL> assert r . status_code == <NUM_LIT:200> <EOL> assert r . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert r . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert r . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert r . headers [ '<STR_LIT>' ] == usock_thread . usock <EOL> assert isinstance ( r . connection , requests_unixsocket . UnixAdapter ) <EOL> assert r . url == url <EOL> if method == '<STR_LIT>' : <EOL> assert r . text == '<STR_LIT>' <EOL> else : <EOL> assert r . text == '<STR_LIT>' <EOL> def test_unix_domain_adapter_url_with_query_params ( ) : <EOL> with UnixSocketServerThread ( ) as usock_thread : <EOL> session = requests_unixsocket . Session ( '<STR_LIT>' ) <EOL> urlencoded_usock = requests . compat . quote_plus ( usock_thread . usock ) <EOL> url = ( '<STR_LIT>' <EOL> '<STR_LIT>' % urlencoded_usock ) <EOL> for method in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] : <EOL> logger . debug ( '<STR_LIT>' , method , url ) <EOL> r = getattr ( session , method ) ( url ) <EOL> logger . debug ( <EOL> '<STR_LIT>' , <EOL> r , r . text , r . headers ) <EOL> assert r . status_code == <NUM_LIT:200> <EOL> assert r . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert r . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert r . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert r . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert r . headers [ '<STR_LIT>' ] == usock_thread . usock <EOL> assert isinstance ( r . connection , requests_unixsocket . UnixAdapter ) <EOL> assert r . url == url <EOL> if method == '<STR_LIT>' : <EOL> assert r . text == '<STR_LIT>' <EOL> else : <EOL> assert r . text == '<STR_LIT>' <EOL> def test_unix_domain_adapter_connection_error ( ) : <EOL> session = requests_unixsocket . Session ( '<STR_LIT>' ) <EOL> for method in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> with pytest . raises ( requests . ConnectionError ) : <EOL> getattr ( session , method ) ( <EOL> '<STR_LIT>' ) <EOL> def test_unix_domain_adapter_connection_proxies_error ( ) : <EOL> session = requests_unixsocket . Session ( '<STR_LIT>' ) <EOL> for method in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> with pytest . raises ( ValueError ) as excinfo : <EOL> getattr ( session , method ) ( <EOL> '<STR_LIT>' , <EOL> proxies = { "<STR_LIT>" : "<STR_LIT>" } ) <EOL> assert ( '<STR_LIT>' <EOL> in str ( excinfo . value ) ) <EOL> def test_unix_domain_adapter_monkeypatch ( ) : <EOL> with UnixSocketServerThread ( ) as usock_thread : <EOL> with requests_unixsocket . monkeypatch ( '<STR_LIT>' ) : <EOL> urlencoded_usock = requests . compat . quote_plus ( usock_thread . usock ) <EOL> url = '<STR_LIT>' % urlencoded_usock <EOL> for method in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] : <EOL> logger . debug ( '<STR_LIT>' , method , url ) <EOL> r = getattr ( requests , method ) ( url ) <EOL> logger . debug ( <EOL> '<STR_LIT>' , <EOL> r , r . text , r . headers ) <EOL> assert r . status_code == <NUM_LIT:200> <EOL> assert r . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert r . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert r . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert r . headers [ '<STR_LIT>' ] == usock_thread . usock <EOL> assert isinstance ( r . connection , <EOL> requests_unixsocket . UnixAdapter ) <EOL> assert r . url == url <EOL> if method == '<STR_LIT>' : <EOL> assert r . text == '<STR_LIT>' <EOL> else : <EOL> assert r . text == '<STR_LIT>' <EOL> for method in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> with pytest . raises ( requests . exceptions . InvalidSchema ) : <EOL> getattr ( requests , method ) ( url ) </s>
