diff --git a/requests/sessions.py b/requests/sessions.py index a46957ff..758e6eab 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -97,7 +97,7 @@ class SessionRedirectMixin(object): prepared_request = req.copy() if i > 0: - #create deep copy of the history and keep track of redirects + #update history and keep track of redirects hist.append(resp) new_hist = list(hist) resp.history = new_hist diff --git a/test_requests.py b/test_requests.py index aa4a2745..34ebd8ca 100755 --- a/test_requests.py +++ b/test_requests.py @@ -976,10 +976,11 @@ class RequestsTestCase(unittest.TestCase): def test_requests_history_is_saved(self): r = requests.get('https://httpbin.org/redirect/5') - count = 0 + total = r.history[-1].history + i = 0 for item in r.history: - assert len(item.history) == count - count = count + 1 + assert item.history == total[0:i] + i=i+1 class TestContentEncodingDetection(unittest.TestCase):