Added test for domain name no_proxy matching.
authorKamil Madac <kamil.madac@gmail.com>
Mon, 2 Dec 2013 21:40:26 +0000 (22:40 +0100)
committerKamil Madac <kamil.madac@gmail.com>
Mon, 2 Dec 2013 21:40:26 +0000 (22:40 +0100)
.idea/dictionaries/kmadac.xml [new file with mode: 0644]
test_requests.py

diff --git a/.idea/dictionaries/kmadac.xml b/.idea/dictionaries/kmadac.xml
new file mode 100644 (file)
index 0000000..93bbf4d
--- /dev/null
@@ -0,0 +1,3 @@
+<component name="ProjectDictionaryState">
+  <dictionary name="kmadac" />
+</component>
\ No newline at end of file
index cb91ade..4aa86c3 100755 (executable)
@@ -917,7 +917,15 @@ class UtilsTestCase(unittest.TestCase):
         assert get_environ_proxies('http://192.168.0.1:5000/') == {}
         assert get_environ_proxies('http://192.168.0.1/') == {}
         assert get_environ_proxies('http://172.16.1.1/') == {}
+        assert get_environ_proxies('http://172.16.1.1:5000/') == {}
         assert get_environ_proxies('http://192.168.1.1:5000/') == {'no': os.environ['no_proxy']}
 
+    def test_get_environ_proxies(self):
+        """ Ensures that IP addresses are correctly matches with ranges in no_proxy variable """
+        from requests.utils import get_environ_proxies
+        os.environ['no_proxy'] = "127.0.0.1,localhost.localdomain,192.168.0.0/24,172.16.1.1"
+        assert get_environ_proxies('http://localhost.localdomain:5000/test/') == {}
+        assert get_environ_proxies('http://www.requests.com/') == {'no': os.environ['no_proxy']}
+
 if __name__ == '__main__':
     unittest.main()