From: Ian Cordasco Date: Sat, 18 Aug 2012 18:41:13 +0000 (-0400) Subject: Fix python3 tests. X-Git-Tag: v0.13.7~3^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab56e4a9f170c2c951d443853466f27b31dcc256;p=services%2Fpython-requests.git Fix python3 tests. I wasn't thorough enough with how I dealt with headers. Most of the header logic in the Request object utilizes dictionary properties which will not work with a key/value list. I'll dig more into this, but I know the rest of the features are more important so I'll take my time on this and send a separate pull request. --- diff --git a/requests/sessions.py b/requests/sessions.py index cd6daa6..cd05490 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -72,7 +72,8 @@ class Session(object): verify=True, cert=None): - self.headers = to_key_val_list(headers or []) + #self.headers = to_key_val_list(headers or []) + self.headers = headers or {} self.auth = auth self.timeout = timeout self.proxies = to_key_val_list(proxies or []) @@ -160,7 +161,7 @@ class Session(object): # Default empty dicts for dict params. data = [] if data is None else data files = [] if files is None else files - headers = [] if headers is None else headers + headers = {} if headers is None else headers params = [] if params is None else params hooks = {} if hooks is None else hooks prefetch = prefetch if prefetch is not None else self.prefetch @@ -171,10 +172,10 @@ class Session(object): # Expand header values. if headers: - expanded = [] - for k, v in to_key_val_list(headers): - expanded.append((k, header_expand(v))) - headers = expanded + #e = [(k, header_expand(v)) for k, v in to_key_val_list(headers)] + #headers = e + for k, v in list(headers.items()) or {}: + headers[k] = header_expand(v) args = dict( method=method, diff --git a/tests/test_requests.py b/tests/test_requests.py index b7dba36..29ea980 100755 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -977,7 +977,7 @@ class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase): # Don't choke on headers with none in the value. requests.get(httpbin('headers'), headers={'Foo': None}) except TypeError: - self.fail() + self.fail('Not able to have none in header values') def test_danger_mode_redirects(self): s = requests.session()