#NEWLINE# @ urlmatch ( netloc = '(.*\\.)?api\\.weixin\\.qq\\.com$' ) #NEWLINE# def wechat_api_mock( url , request ) : #NEWLINE# #INDENT# path = url . path . replace ( '/cgi-bin/component/' , '' ) . replace ( '/' , '_' ) #NEWLINE# res_file = os . path . join ( _FIXTURE_PATH , ( '%s.json' % path ) ) #NEWLINE# content = { #NEWLINE# #INDENT# 'errcode' : 99999 , #NEWLINE# 'errmsg' : ( 'can not find fixture %s' % res_file ) , #NEWLINE# #UNINDENT# } #NEWLINE# headers = { #NEWLINE# #INDENT# 'Content-Type' : 'application/json' , #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# with open ( res_file , 'rb' ) as f : #NEWLINE# #INDENT# content = json . loads ( f . read ( ) . decode ( 'utf-8' ) ) #NEWLINE# #UNINDENT# #UNINDENT# except ( IOError , ValueError ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# return response ( 200 , content , headers , request = request )