@@ -131,42 +131,6 @@ def test_not_bypass(self, url):
131131 assert get_environ_proxies (url ) != {}
132132
133133
134- class TestShouldBypassProxies :
135- """
136- Tests for should_bypass_proxies function
137- """
138-
139- @pytest .mark .parametrize (
140- 'url, expected' , (
141- ('http://192.168.0.1:5000/' , True ),
142- ('http://192.168.0.1/' , True ),
143- ('http://172.16.1.1/' , True ),
144- ('http://172.16.1.1:5000/' , True ),
145- ('http://localhost.localdomain:5000/v1.0/' , True ),
146- ))
147- def test_should_bypass_proxies (self , url , expected , monkeypatch ):
148- """
149- Test to check if proxy is bypassed
150- """
151- monkeypatch .setenv ('no_proxy' , '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1' )
152- monkeypatch .setenv ('NO_PROXY' , '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1' )
153- assert should_bypass_proxies (url ) == expected
154-
155- @pytest .mark .parametrize (
156- 'url, expected' , (
157- ('http://172.16.1.12/' , False ),
158- ('http://172.16.1.12:5000/' , False ),
159- ('http://google.com:5000/v1.0/' , False ),
160- ))
161- def test_should_bypass_proxies (self , url , expected , monkeypatch ):
162- """
163- Test to check if proxy is not bypassed
164- """
165- monkeypatch .setenv ('no_proxy' , '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1' )
166- monkeypatch .setenv ('NO_PROXY' , '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1' )
167- assert should_bypass_proxies (url ) == expected
168-
169-
170134class TestIsIPv4Address :
171135
172136 def test_valid (self ):
@@ -464,3 +428,23 @@ def test_to_native_string(value, expected):
464428 ))
465429def test_urldefragauth (url , expected ):
466430 assert urldefragauth (url ) == expected
431+
432+
433+ @pytest .mark .parametrize (
434+ 'url, expected' , (
435+ ('http://192.168.0.1:5000/' , True ),
436+ ('http://192.168.0.1/' , True ),
437+ ('http://172.16.1.1/' , True ),
438+ ('http://172.16.1.1:5000/' , True ),
439+ ('http://localhost.localdomain:5000/v1.0/' , True ),
440+ ('http://172.16.1.12/' , False ),
441+ ('http://172.16.1.12:5000/' , False ),
442+ ('http://google.com:5000/v1.0/' , False ),
443+ ))
444+ def test_should_bypass_proxies (url , expected , monkeypatch ):
445+ """
446+ Tests for function should_bypass_proxies to check if proxy can be bypassed or not
447+ """
448+ monkeypatch .setenv ('no_proxy' , '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1' )
449+ monkeypatch .setenv ('NO_PROXY' , '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1' )
450+ assert should_bypass_proxies (url ) == expected
0 commit comments