From: Shivaram Lingamneni Date: Thu, 6 Sep 2012 23:31:01 +0000 (-0700) Subject: fix some tests to correctly cover the API X-Git-Tag: v0.14.1~7^2~9^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c73646da0018063f7ddd03514e6cde55e82bb640;p=services%2Fpython-requests.git fix some tests to correctly cover the API After #831, the tests added in #764 (which relied on iter_content() crashing if the response was prefetched) no longer tested what they were intended to test. --- diff --git a/tests/test_requests.py b/tests/test_requests.py index 9f4e819..f8a31f2 100755 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -1058,9 +1058,9 @@ class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase): def test_prefetch_redirect_bug(self): """Test that prefetch persists across redirections.""" res = get(httpbin('redirect/2'), prefetch=False) - # prefetch should persist across the redirect; if it doesn't, - # this attempt to iterate will crash because the content has already - # been read. + # prefetch should persist across the redirect; + # the content should not have been consumed + self.assertFalse(res._content_consumed) first_line = next(res.iter_lines()) self.assertTrue(first_line.strip().decode('utf-8').startswith('{')) @@ -1068,7 +1068,8 @@ class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase): """Test that prefetch can be overridden as a kwarg to `send`.""" req = requests.get(httpbin('get'), return_response=False) req.send(prefetch=False) - # content should not have been prefetched, and iter_lines should succeed + # content should not have been prefetched + self.assertFalse(req.response._content_consumed) first_line = next(req.response.iter_lines()) self.assertTrue(first_line.strip().decode('utf-8').startswith('{'))