Skip to content
Myr

Allow None value for chunk_size again (#3368)

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

authored by Joy Zheng · committed by Ian Cordasco · parent 92fe51c · Browse files · 2 files+8 added−3 removed
This commit

State

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

Diff stats

2 files+8 added−3 removed

  • tests:+7 added−2 removed
  • other:+1 added−1 removed

2 files+8 added−3 removed

modified:requests/models.py+1 added-1 removed
683 unmodified lines
684 self._content_consumed = True685686 if self._content_consumed and isinstance(self._content, bool):687 raise StreamConsumedError()688 elif not isinstance(chunk_size, int):688 elif chunk_size is not None and not isinstance(chunk_size, int):689 raise TypeError("chunk_size must be an int, it is instead a %s." % type(chunk_size))690 # simulate reading small chunks of the content691 reused_chunks = iter_slices(self._content, chunk_size)692
169 unmodified lines
modified:tests/test_requests.py+7 added-2 removed
985 unmodified lines
986 r.encoding = None987 chunks = r.iter_content(decode_unicode=True)988 assert all(isinstance(chunk, str) for chunk in chunks)989990 def test_response_chunk_size_int(self):991 """Ensure that chunk_size is passed as an integer, otherwise990 def test_response_chunk_size_type(self):991 """Ensure that chunk_size is passed as None or an integer, otherwise992 raise a TypeError.993 """994 r = requests.Response()995 r.raw = io.BytesIO(b'the content')
1 unmodified line
997 assert all(len(chunk) == 1 for chunk in chunks)998999 r = requests.Response()1000 r.raw = io.BytesIO(b'the content')1001 chunks = r.iter_content(None)1002 assert list(chunks) == [b'the content']10031004 r = requests.Response()1005 r.raw = io.BytesIO(b'the content')1006 with pytest.raises(TypeError):1007 chunks = r.iter_content("1024")10081009 def test_request_and_response_are_pickleable(self, httpbin):
714 unmodified lines