File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -378,7 +378,7 @@ def from_http_response(response):
378378 error_message = payload .get ('error' , {}).get ('message' , 'unknown error' )
379379 errors = payload .get ('error' , {}).get ('errors' , ())
380380
381- message = '{method} {url}: {error}' .format (
381+ message = u '{method} {url}: {error}' .format (
382382 method = response .request .method ,
383383 url = response .request .url ,
384384 error = error_message )
Original file line number Diff line number Diff line change @@ -135,6 +135,22 @@ def test_from_http_response_bad_json_content():
135135 assert exception .message == 'POST https://example.com/: unknown error'
136136
137137
138+ def test_from_http_response_json_unicode_content ():
139+ response = make_response (json .dumps ({
140+ 'error' : {
141+ 'message' : u'\u2019 message' ,
142+ 'errors' : ['1' , '2' ]
143+ }
144+ }).encode ('utf-8' ))
145+
146+ exception = exceptions .from_http_response (response )
147+
148+ assert isinstance (exception , exceptions .NotFound )
149+ assert exception .code == http_client .NOT_FOUND
150+ assert exception .message == u'POST https://example.com/: \u2019 message'
151+ assert exception .errors == ['1' , '2' ]
152+
153+
138154def test_from_grpc_status ():
139155 message = 'message'
140156 exception = exceptions .from_grpc_status (
You can’t perform that action at this time.
0 commit comments