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.
This commit is contained in:
Ian Cordasco
2012-08-18 14:41:13 -04:00
parent f01694e274
commit ab56e4a9f1
2 changed files with 8 additions and 7 deletions
+7 -6
View File
@@ -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,
+1 -1
View File
@@ -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()