Skip to content
Myr

Fix python3 tests.

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

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.

authored by Ian Cordasco · committed by Ian Cordasco · parent f01694e · Browse files · 2 files+8 added−7 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−7 removed

  • tests:+1 added−1 removed
  • other:+7 added−6 removed

2 files+8 added−7 removed

modified:requests/sessions.py+7 added-6 removed
70 unmodified lines
71 prefetch=True,72 verify=True,73 cert=None):7475 self.headers = to_key_val_list(headers or [])75 #self.headers = to_key_val_list(headers or [])76 self.headers = headers or {}77 self.auth = auth78 self.timeout = timeout79 self.proxies = to_key_val_list(proxies or [])80 self.hooks = hooks or {}
79 unmodified lines
160161 # Default empty dicts for dict params.162 data = [] if data is None else data163 files = [] if files is None else files163 headers = [] if headers is None else headers164 headers = {} if headers is None else headers165 params = [] if params is None else params166 hooks = {} if hooks is None else hooks167 prefetch = prefetch if prefetch is not None else self.prefetch168
2 unmodified lines
171 hooks.setdefault(key, cb)172173 # Expand header values.174 if headers:174 expanded = []175 for k, v in to_key_val_list(headers):176 expanded.append((k, header_expand(v)))177 headers = expanded175 #e = [(k, header_expand(v)) for k, v in to_key_val_list(headers)]176 #headers = e177 for k, v in list(headers.items()) or {}:178 headers[k] = header_expand(v)179180 args = dict(181 method=method,182 url=url,
148 unmodified lines
modified:tests/test_requests.py+1 added-1 removed
975 unmodified lines
976 try:977 # Don't choke on headers with none in the value.978 requests.get(httpbin('headers'), headers={'Foo': None})979 except TypeError:980 self.fail()980 self.fail('Not able to have none in header values')981982 def test_danger_mode_redirects(self):983 s = requests.session()984 s.config['danger_mode'] = True
141 unmodified lines