From 2fc6e8a894a5378dd16b2653df9ccf875d0bddf8 Mon Sep 17 00:00:00 2001 From: ContinuousFunction Date: Tue, 19 Aug 2014 10:51:26 -0700 Subject: [PATCH] Update on Tracking Previous Requests Modified the comment in sessions.py and rewrote the test in test_requests.py --- requests/sessions.py | 2 +- test_requests.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) 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):