Skip to content
Myr

Merge pull request #3510 from nateprewitt/add_close_passthrough

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

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

authored by Cory Benfield · committed by GitHub · parents 33501c7, 59f12c9 · 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
1391 unmodified lines
1392 assert r.content is None1393 with pytest.raises(ValueError):1394 r.json()13951396 def test_response_without_release_conn(self):1397 """Test `close` call for non-urllib3-like raw objects.1398 Should work when `release_conn` attr doesn't exist on `response.raw`.1399 """1400 resp = requests.Response()1401 resp.raw = StringIO.StringIO('test')1402 assert not resp.raw.closed1403 resp.close()1404 assert resp.raw.closed14051406class TestCaseInsensitiveDict:14071408 @pytest.mark.parametrize(
416 unmodified lines