Skip to content

Commit

Permalink
building Response manually
Browse files Browse the repository at this point in the history
  • Loading branch information
nateprewitt committed Aug 11, 2016
1 parent e50c61b commit 3acd5a5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,16 @@ def test_transfer_enc_removal_on_redirect(self, httpbin):
req = requests.Request('POST', httpbin('post'), data=(b'x' for x in range(1)))
prep = ses.prepare_request(req)
assert 'Transfer-Encoding' in prep.headers
resp = ses.send(prep)

# Create Response to avoid https://github.com/kevin1024/pytest-httpbin/issues/33
resp = requests.Response()
resp.raw = io.BytesIO(b'the content')
setattr(resp.raw, 'release_conn', lambda *args: args)

# Mimic a redirect response
resp.status_code = 302
resp.headers['location'] = 'get'
resp.headers['location'] = httpbin('get')
resp.request = prep

# Run request through resolve_redirect
next_resp = next(ses.resolve_redirects(resp, prep))
Expand Down

0 comments on commit 3acd5a5

Please sign in to comment.