Skip to content

Commit

Permalink
Merge pull request #132 from whs/master
Browse files Browse the repository at this point in the history
Added reason to mocked HTTPResponse
  • Loading branch information
dcramer authored Dec 15, 2016
2 parents 47c05a4 + d269a2a commit fa312f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def _on_request(self, adapter, request, **kwargs):

response = HTTPResponse(
status=status,
reason=six.moves.http_client.responses[status],
body=body,
headers=headers,
preload_content=False,
Expand Down
3 changes: 3 additions & 0 deletions test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def assert_reset():

def assert_response(resp, body=None, content_type='text/plain'):
assert resp.status_code == 200
assert resp.reason == 'OK'
assert resp.headers['Content-Type'] == content_type
assert resp.text == body

Expand Down Expand Up @@ -190,6 +191,7 @@ def run():
def test_callback():
body = b'test callback'
status = 400
reason = 'Bad Request'
headers = {'foo': 'bar'}
url = 'http://example.com/'

Expand All @@ -202,6 +204,7 @@ def run():
resp = requests.get(url)
assert resp.text == "test callback"
assert resp.status_code == status
assert resp.reason == reason
assert 'foo' in resp.headers
assert resp.headers['foo'] == 'bar'

Expand Down

0 comments on commit fa312f5

Please sign in to comment.