#NEWLINE# def test_process_response_encoding_inside_body( self ) : #NEWLINE# #INDENT# headers = { #NEWLINE# #INDENT# 'Content-Type' : 'text/html' , #NEWLINE# 'Content-Encoding' : 'gzip' , #NEWLINE# #UNINDENT# } #NEWLINE# f = BytesIO ( ) #NEWLINE# plainbody = b'<html><head><title>Some page</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312">' #NEWLINE# zf = GzipFile ( fileobj = f , mode = 'wb' ) #NEWLINE# zf . write ( plainbody ) #NEWLINE# zf . close ( ) #NEWLINE# response = Response ( 'http;//www.example.com/' , headers = headers , body = f . getvalue ( ) ) #NEWLINE# request = Request ( 'http://www.example.com/' ) #NEWLINE# newresponse = self . mw . process_response ( newresponse , response , self . spider ) #NEWLINE# assert isinstance ( newresponse , HtmlResponse ) #NEWLINE# self . assertEqual ( newresponse . body , plainbody ) #NEWLINE# self . assertEqual ( newresponse . encoding , resolve_encoding ( 'gb2312' ) )