diff --git a/responses.py b/responses.py index 787f34c0..f26bb80e 100644 --- a/responses.py +++ b/responses.py @@ -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, diff --git a/test_responses.py b/test_responses.py index 397d1af9..0924ced6 100644 --- a/test_responses.py +++ b/test_responses.py @@ -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 @@ -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/' @@ -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'