Python 3: fix test_httpretty_should_allow_registering_regexes_with_streaming_responses()

This was cause by the use of text strings instead of bytes.
This commit is contained in:
Cyril Roelandt
2014-01-13 16:21:13 +01:00
parent d272b60051
commit 4b5db343a9
2 changed files with 4 additions and 4 deletions

View File

@@ -363,10 +363,10 @@ class fakesock(object):
if not is_parsing_headers:
if len(self._sent_data) > 1:
headers = utf8(last_requestline(self._sent_data))
meta = dict(self._entry.request.headers)
meta = self._entry.request.headers
body = utf8(self._sent_data[-1])
if meta.get('transfer-encoding', '') == 'chunked':
if not body.isdigit() and body != '\r\n' and body != '0\r\n\r\n':
if not body.isdigit() and body != b'\r\n' and body != b'0\r\n\r\n':
self._entry.request.body += body
else:
self._entry.request.body += body

View File

@@ -575,7 +575,7 @@ def test_httpretty_should_allow_registering_regexes_with_streaming_responses():
os.environ['DEBUG'] = 'true'
def my_callback(request, url, headers):
request.body.should.equal('hithere')
request.body.should.equal(b'hithere')
return 200, headers, "Received"
HTTPretty.register_uri(
@@ -592,7 +592,7 @@ def test_httpretty_should_allow_registering_regexes_with_streaming_responses():
'https://api.yipit.com/v1/deal;brand=gap?first_name=chuck&last_name=norris',
data=gen(),
)
expect(response.content).to.equal("Received")
expect(response.content).to.equal(b"Received")
expect(HTTPretty.last_request.method).to.equal('POST')
expect(HTTPretty.last_request.path).to.equal('/v1/deal;brand=gap?first_name=chuck&last_name=norris')