Skip to content
Myr

fix some tests to correctly cover the API

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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.

authored by Shivaram Lingamneni · committed by Shivaram Lingamneni · parent c8f166f · Browse files · 1 file+5 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−4 removed

  • tests:+5 added−4 removed

1 file+5 added−4 removed

modified:tests/test_requests.py+5 added-4 removed
1056 unmodified lines
10571058 def test_prefetch_redirect_bug(self):1059 """Test that prefetch persists across redirections."""1060 res = get(httpbin('redirect/2'), prefetch=False)1061 # prefetch should persist across the redirect; if it doesn't,1062 # this attempt to iterate will crash because the content has already1063 # been read.1061 # prefetch should persist across the redirect;1062 # the content should not have been consumed1063 self.assertFalse(res._content_consumed)1064 first_line = next(res.iter_lines())1065 self.assertTrue(first_line.strip().decode('utf-8').startswith('{'))10661067 def test_prefetch_return_response_interaction(self):1068 """Test that prefetch can be overridden as a kwarg to `send`."""1069 req = requests.get(httpbin('get'), return_response=False)1070 req.send(prefetch=False)1071 # content should not have been prefetched, and iter_lines should succeed1071 # content should not have been prefetched1072 self.assertFalse(req.response._content_consumed)1073 first_line = next(req.response.iter_lines())1074 self.assertTrue(first_line.strip().decode('utf-8').startswith('{'))10751076 def test_accept_objects_with_string_representations_as_urls(self):
69 unmodified lines