Skip to content
Myr

Merge pull request #1962 from sigmavirus24/fix-history-type

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

Fix #1960: A Response's history should be a list

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 5f48e4a, 8fc6a65 · Browse files · 2 files+11 added−1 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+11 added−1 removed

  • other:+11 added−1 removed

2 files+11 added−1 removed

modified:requests/sessions.py+1 added-1 removed
584 unmodified lines
585 # Insert the first (original) request at the start586 history.insert(0, r)587 # Get the last request made588 r = history.pop()589 r.history = tuple(history)589 r.history = history590591 return r592593 def get_adapter(self, url):
37 unmodified lines
modified:test_requests.py+10 added
212 unmodified lines
213 urls = [r.url for r in resp.history]214 req_urls = [r.request.url for r in resp.history]215 assert urls == req_urls216217 def test_history_is_always_a_list(self):218 """219 Show that even with redirects, Response.history is always a list.220 """221 resp = requests.get(httpbin('get'))222 assert isinstance(resp.history, list)223 resp = requests.get(httpbin('redirect/1'))224 assert isinstance(resp.history, list)225 assert not isinstance(resp.history, tuple)226227 def test_headers_on_session_with_None_are_not_sent(self):228 """Do not send headers in Session.headers with None values."""229 ses = requests.Session()230 ses.headers['Accept-Encoding'] = None
1049 unmodified lines