Fix #1960: A Response's history should be a list
authorIan Cordasco <graffatcolmingov@gmail.com>
Sat, 15 Mar 2014 15:33:00 +0000 (10:33 -0500)
committerIan Cordasco <graffatcolmingov@gmail.com>
Sat, 15 Mar 2014 15:33:00 +0000 (10:33 -0500)
requests/sessions.py
test_requests.py

index 425db22ca6fbe6e422b1e6dd61f9185915adf372..1e6de8b2d89d7e60b8310cbdb701f3c49e2f4435 100644 (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
 
index 17de84911bb32db1df00aef1224f3bc917864e92..76943f2c49d50a1f039b91cd7ee7b857389e620c 100755 (executable)
@@ -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()