Merge pull request #1482 from dpursehouse/fix-testcases-with-proxy

Fix test cases that fail when running behind a proxy
This commit is contained in:
Kenneth Reitz
2013-07-23 05:23:35 -07:00
2 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -214,7 +214,7 @@ class HTTPAdapter(BaseAdapter):
If the message is being sent through a proxy, the full URL has to be
used. Otherwise, we should only use the path portion of the URL.
This shoudl not be called from user code, and is only exposed for use
This should not be called from user code, and is only exposed for use
when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
+7 -1
View File
@@ -12,7 +12,7 @@ import pickle
import requests
from requests.auth import HTTPDigestAuth
from requests.adapters import HTTPAdapter
from requests.compat import str, cookielib
from requests.compat import str, cookielib, getproxies
from requests.cookies import cookiejar_from_dict
from requests.exceptions import InvalidURL, MissingSchema
from requests.structures import CaseInsensitiveDict
@@ -90,11 +90,14 @@ class RequestsTestCase(unittest.TestCase):
"http://example.com/path?key=value&a=b#fragment")
def test_mixed_case_scheme_acceptable(self):
proxies = getproxies()
s = requests.Session()
s.proxies = proxies
r = requests.Request('GET', 'http://httpbin.org/get')
r = s.send(r.prepare())
self.assertEqual(r.status_code,200)
s = requests.Session()
s.proxies = proxies
r = requests.Request('GET', 'HTTP://httpbin.org/get')
r = s.send(r.prepare())
self.assertEqual(r.status_code,200)
@@ -120,6 +123,7 @@ class RequestsTestCase(unittest.TestCase):
def test_HTTP_200_OK_GET_ALTERNATIVE(self):
r = requests.Request('GET', httpbin('get'))
s = requests.Session()
s.proxies = getproxies()
r = s.send(r.prepare())
@@ -449,6 +453,7 @@ class RequestsTestCase(unittest.TestCase):
prep = req.prepare()
s = requests.Session()
s.proxies = getproxies()
resp = s.send(prep)
self.assertTrue(hasattr(resp, 'hook_working'))
@@ -538,6 +543,7 @@ class RequestsTestCase(unittest.TestCase):
s = requests.Session()
s = pickle.loads(pickle.dumps(s))
s.proxies = getproxies()
r = s.send(r.prepare())
self.assertEqual(r.status_code, 200)