HTMLTestRunner測試報告中文亂碼問題解決


在學習python selenium自動化測試學習中遇到HTMLTestRunner測試報告出現亂碼的問題

測試報告

Test Group/Test case Count Pass Fail Error View
baidu.Baidu 1 1 0 0 Detail
test_baidu_search: 百度搜索
pass
login_Verification.OA 2 2 0 0 Detail
test_login: 登錄驗證
pass

網上查找到HTMLTestRunner測試報告中文亂碼的解決方案:

(1)打開HTMLTestRunner.py源文件,找到如下行

# o and e should be byte string because they are collected from stdout and stderr?
        if isinstance(o,str):
            # TODO: some problem with 'string_escape': it escape \n and mess up formating # uo = unicode(o.encode('string_escape'))  uo = o.decode('latin-1') else: uo = o if isinstance(e,str): # TODO: some problem with 'string_escape': it escape \n and mess up formating # ue = unicode(e.encode('string_escape'))  ue = e.decode('latin-1') else: ue = e

(2)添加utf-8的解碼

 

 

# o and e should be byte string because they are collected from stdout and stderr?
        if isinstance(o,str):
            # TODO: some problem with 'string_escape': it escape \n and mess up formating # uo = unicode(o.encode('string_escape')) #uo = o.decode('latin-1') uo = o.decode('utf-8') else: uo = o if isinstance(e,str): # TODO: some problem with 'string_escape': it escape \n and mess up formating # ue = unicode(e.encode('string_escape'))  #ue = e.decode('latin-1') ue = e.decode('utf-8') else: ue = e

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM