diff options
| author | Kumar Varadarajulu <kumar.varadarajulu@dealertrack.com> | 2016-05-16 10:49:37 +0000 |
|---|---|---|
| committer | Kumar Varadarajulu <kumar.varadarajulu@dealertrack.com> | 2016-05-16 10:49:37 +0000 |
| commit | b94decc47c1026067b99e4452ddabec1ad139845 (patch) | |
| tree | e43f43d6e4182140be0f6339badc71283863bd4a /tests/test_utils.py | |
| parent | f59a95713ebefcbcf4baf247d9ef193d5e8b83b0 (diff) | |
| download | python-requests-b94decc47c1026067b99e4452ddabec1ad139845.tar.gz | |
Combined tests to one tests for should_bypass_proxies method
Diffstat (limited to 'tests/test_utils.py')
| -rw-r--r-- | tests/test_utils.py | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py index 3da5dc3c..68e5a173 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -131,42 +131,6 @@ class TestGetEnvironProxies: assert get_environ_proxies(url) != {} -class TestShouldBypassProxies: - """ - Tests for should_bypass_proxies function - """ - - @pytest.mark.parametrize( - 'url, expected', ( - ('http://192.168.0.1:5000/', True), - ('http://192.168.0.1/', True), - ('http://172.16.1.1/', True), - ('http://172.16.1.1:5000/', True), - ('http://localhost.localdomain:5000/v1.0/', True), - )) - def test_should_bypass_proxies(self, url, expected, monkeypatch): - """ - Test to check if proxy is bypassed - """ - monkeypatch.setenv('no_proxy', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1') - monkeypatch.setenv('NO_PROXY', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1') - assert should_bypass_proxies(url) == expected - - @pytest.mark.parametrize( - 'url, expected', ( - ('http://172.16.1.12/', False), - ('http://172.16.1.12:5000/', False), - ('http://google.com:5000/v1.0/', False), - )) - def test_should_bypass_proxies(self, url, expected, monkeypatch): - """ - Test to check if proxy is not bypassed - """ - monkeypatch.setenv('no_proxy', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1') - monkeypatch.setenv('NO_PROXY', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1') - assert should_bypass_proxies(url) == expected - - class TestIsIPv4Address: def test_valid(self): @@ -464,3 +428,23 @@ def test_to_native_string(value, expected): )) def test_urldefragauth(url, expected): assert urldefragauth(url) == expected + + +@pytest.mark.parametrize( + 'url, expected', ( + ('http://192.168.0.1:5000/', True), + ('http://192.168.0.1/', True), + ('http://172.16.1.1/', True), + ('http://172.16.1.1:5000/', True), + ('http://localhost.localdomain:5000/v1.0/', True), + ('http://172.16.1.12/', False), + ('http://172.16.1.12:5000/', False), + ('http://google.com:5000/v1.0/', False), + )) +def test_should_bypass_proxies(url, expected, monkeypatch): + """ + Tests for function should_bypass_proxies to check if proxy can be bypassed or not + """ + monkeypatch.setenv('no_proxy', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1') + monkeypatch.setenv('NO_PROXY', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1') + assert should_bypass_proxies(url) == expected |
