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

This commit is contained in:
Ian Cordasco
2014-03-15 10:33:00 -05:00
parent 110048f983
commit daf56b3f62
2 changed files with 10 additions and 1 deletions
-1
View File
@@ -527,7 +527,6 @@ class Session(SessionRedirectMixin):
history.insert(0, r)
# Get the last request made
r = history.pop()
r.history = tuple(history)
return r
+10
View File
@@ -211,6 +211,16 @@ class RequestsTestCase(unittest.TestCase):
req_urls = [r.request.url for r in resp.history]
assert urls == req_urls
def test_history_is_always_a_list(self):
"""
Show that even with redirects, Response.history is always a list.
"""
resp = requests.get(httpbin('get'))
assert isinstance(resp.history, list)
resp = requests.get(httpbin('redirect/1'))
assert isinstance(resp.history, list)
assert not isinstance(resp.history, tuple)
def test_headers_on_session_with_None_are_not_sent(self):
"""Do not send headers in Session.headers with None values."""
ses = requests.Session()