@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):
 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://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 ) : 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 )
tests for function should_bypass_proxies to check if proxy can be bypassed or not .