Skip to content
Myr

adding passthrough in close() for non-urllib3-like Responses

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

authored by Nate Prewitt · committed by Nate Prewitt · parent e4b7040 · Browse files · 2 files+12 added−1 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+12 added−1 removed

  • tests:+9 added−0 removed
  • other:+3 added−1 removed

2 files+12 added−1 removed

modified:requests/models.py+3 added-1 removed
868 unmodified lines
869 """870 if not self._content_consumed:871 self.raw.close()872873 return self.raw.release_conn()873 release_conn = getattr(self.raw, 'release_conn', None)874 if release_conn is not None:875 release_conn()
modified:tests/test_requests.py+9 added
1351 unmodified lines
1352 assert r.content is None1353 with pytest.raises(ValueError):1354 r.json()13551356 def test_response_without_release_conn(self):1357 """Test `close` call for non-urllib3-like raw objects.1358 Should work when `release_conn` attr doesn't exist on `response.raw`.1359 """1360 resp = requests.Response()1361 resp.raw = StringIO.StringIO('test')1362 assert not resp.raw.closed1363 resp.close()1364 assert resp.raw.closed13651366class TestCaseInsensitiveDict:13671368 @pytest.mark.parametrize(
416 unmodified lines