HTMLTestRunner的報告中文亂碼

2021-08-20 05:19:26 字數 1098 閱讀 5168

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

解決辦法:

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

(1)開啟htmltestrunner.py原始檔,找到如下行

if isinstance(o,str):

# 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的解碼

學習HTMLTestRunner筆記

2.在 中執行之前要先導入htmltestrunner模組。至於你下的py模組你能不能用在idle中import一下就知道了 3.下面貼 來解釋吧,總之報告這塊有不少的坑!哎 coding utf 8 importunittest importbaidu,youdao 匯入需要測試的測試用例 imp...

HTMLTestRunner 異常輸出中文亂碼

webdriver for python使用htmltestrunner 輸出測試報告時,標題和描述有中文都不會顯示亂碼。只有在用例失敗或異常時,輸出的錯誤資訊中中文就顯示亂碼,如下 解決方案 找到htmltestrunner.py原始碼 定位到如下位置,o.decode latin 1 編碼 la...

使用HTMLTestRunner生成測試報告

一 htmltestrunner的安裝 2 將htmltestrunner.py檔案拷貝到python lib目錄下 3 驗證安裝是否正確,如下圖。importhtmltestrunner 引入htmltestrunner 定義測試集合 ts unittest.testsuite 建立測試套件 no...