Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix test cases that fail when running behind a proxy

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 47f5a0d, 9e771aa · Browse files · 2 files+8 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−2 removed

  • other:+8 added−2 removed

2 files+8 added−2 removed

modified:requests/adapters.py+1 added-1 removed
212 unmodified lines
213214 If the message is being sent through a proxy, the full URL has to be215 used. Otherwise, we should only use the path portion of the URL.216217 This shoudl not be called from user code, and is only exposed for use217 This should not be called from user code, and is only exposed for use218 when subclassing the219 :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.220221 :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
121 unmodified lines
modified:test_requests.py+7 added-1 removed
10 unmodified lines
1112import requests13from requests.auth import HTTPDigestAuth14from requests.adapters import HTTPAdapter15from requests.compat import str, cookielib15from requests.compat import str, cookielib, getproxies16from requests.cookies import cookiejar_from_dict17from requests.exceptions import InvalidURL, MissingSchema18from requests.structures import CaseInsensitiveDict19
69 unmodified lines
89 self.assertEqual(request.url,90 "http://example.com/path?key=value&a=b#fragment")9192 def test_mixed_case_scheme_acceptable(self):93 proxies = getproxies()94 s = requests.Session()95 s.proxies = proxies96 r = requests.Request('GET', 'http://httpbin.org/get')97 r = s.send(r.prepare())98 self.assertEqual(r.status_code,200)99 s = requests.Session()100 s.proxies = proxies101 r = requests.Request('GET', 'HTTP://httpbin.org/get')102 r = s.send(r.prepare())103 self.assertEqual(r.status_code,200)104 r = requests.Request('GET', 'hTTp://httpbin.org/get')
17 unmodified lines
122123 def test_HTTP_200_OK_GET_ALTERNATIVE(self):124 r = requests.Request('GET', httpbin('get'))125 s = requests.Session()126 s.proxies = getproxies()127128 r = s.send(r.prepare())129130 self.assertEqual(r.status_code, 200)
321 unmodified lines
452 req = requests.Request('GET', HTTPBIN, hooks={'response': hook})453 prep = req.prepare()454455 s = requests.Session()456 s.proxies = getproxies()457 resp = s.send(prep)458459 self.assertTrue(hasattr(resp, 'hook_working'))460
81 unmodified lines
542 r = requests.Request('GET', httpbin('get'))543 s = requests.Session()544545 s = pickle.loads(pickle.dumps(s))546 s.proxies = getproxies()547548 r = s.send(r.prepare())549 self.assertEqual(r.status_code, 200)550
239 unmodified lines