@@ -296,23 +296,37 @@ def test_encode_payload(self):
296296 j = self .sg ._encode_payload (d )
297297 self .assertTrue (isinstance (j , str ))
298298
299- def test_decode_response (self ):
299+ def test_decode_response_ascii (self ):
300+ self ._assert_decode_resonse (True , u"my data \u00E0 " .encode ('utf8' ))
301+
302+ def test_decode_response_unicode (self ):
303+ self ._assert_decode_resonse (False , u"my data \u00E0 " )
304+
305+ def _assert_decode_resonse (self , ensure_ascii , data ):
300306 """HTTP Response is decoded as JSON or text"""
301307
302308 headers = {
303309 "content-type" : "application/json;charset=utf-8"
304310 }
305311 d = {
306- "this is " : u"my data \u00E0 "
312+ "this is " : data
307313 }
308- j = json .dumps (d , ensure_ascii = False , encoding = "utf-8" )
309- self .assertEqual (d , self .sg ._decode_response (headers , j ))
314+ sg = api .Shotgun (self .config .server_url ,
315+ self .config .script_name ,
316+ self .config .api_key ,
317+ http_proxy = self .config .http_proxy ,
318+ ensure_ascii = ensure_ascii ,
319+ connect = False )
320+
321+ j = json .dumps (d , ensure_ascii = ensure_ascii , encoding = "utf-8" )
322+ self .assertEqual (d , sg ._decode_response (headers , j ))
310323
311324 headers ["content-type" ] = "text/javascript"
312- self .assertEqual (d , self . sg ._decode_response (headers , j ))
325+ self .assertEqual (d , sg ._decode_response (headers , j ))
313326
314327 headers ["content-type" ] = "text/foo"
315- self .assertEqual (j , self .sg ._decode_response (headers , j ))
328+ self .assertEqual (j , sg ._decode_response (headers , j ))
329+
316330
317331 def test_parse_records (self ):
318332 """Parse records to replace thumbnail and local paths"""
0 commit comments