diff options
| author | Ian Cordasco <sigmavirus24@users.noreply.github.com> | 2016-05-17 10:42:31 -0500 |
|---|---|---|
| committer | Ian Cordasco <sigmavirus24@users.noreply.github.com> | 2016-05-17 10:42:31 -0500 |
| commit | cd4e6b9aef4b5d3224a1aae1b3a2cef1b09710a4 (patch) | |
| tree | c7641bbf6b08ad924b9f2440223a3b52d81a658f /tests/test_utils.py | |
| parent | 12e36318272bf77c079774a5c97c5abf23e634bb (diff) | |
| parent | 35744c3e5d212f8841be3a5ab7de3e3b37dda5bb (diff) | |
| download | python-requests-cd4e6b9aef4b5d3224a1aae1b3a2cef1b09710a4.tar.gz | |
Merge pull request #3185 from brettdh/3183-support-all-proxy-env-var
Support ALL_PROXY environment variable
Diffstat (limited to 'tests/test_utils.py')
| -rw-r--r-- | tests/test_utils.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py index 68e5a173..17149d26 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -320,17 +320,28 @@ def test_dotted_netmask(mask, expected): assert dotted_netmask(mask) == expected +http_proxies = {'http': 'http://http.proxy', + 'http://some.host': 'http://some.host.proxy'} +all_proxies = {'all': 'socks5://http.proxy', + 'all://some.host': 'socks5://some.host.proxy'} @pytest.mark.parametrize( - 'url, expected', ( - ('hTTp://u:p@Some.Host/path', 'http://some.host.proxy'), - ('hTTp://u:p@Other.Host/path', 'http://http.proxy'), - ('hTTps://Other.Host', None), - ('file:///etc/motd', None), + 'url, expected, proxies', ( + ('hTTp://u:p@Some.Host/path', 'http://some.host.proxy', http_proxies), + ('hTTp://u:p@Other.Host/path', 'http://http.proxy', http_proxies), + ('hTTp:///path', 'http://http.proxy', http_proxies), + ('hTTps://Other.Host', None, http_proxies), + ('file:///etc/motd', None, http_proxies), + + ('hTTp://u:p@Some.Host/path', 'socks5://some.host.proxy', all_proxies), + ('hTTp://u:p@Other.Host/path', 'socks5://http.proxy', all_proxies), + ('hTTp:///path', 'socks5://http.proxy', all_proxies), + ('hTTps://Other.Host', 'socks5://http.proxy', all_proxies), + + # XXX: unsure whether this is reasonable behavior + ('file:///etc/motd', 'socks5://http.proxy', all_proxies), )) -def test_select_proxies(url, expected): +def test_select_proxies(url, expected, proxies): """Make sure we can select per-host proxies correctly.""" - proxies = {'http': 'http://http.proxy', - 'http://some.host': 'http://some.host.proxy'} assert select_proxy(url, proxies) == expected |
