您的位置:首页 > Web前端 > HTML

37、解决 HTMLTestRunner 中文显示乱码的问题

2017-03-10 14:36 633 查看
1.在自己的测试脚本中加入下面的代码并保存:
# -.- coding:utf-8 -.-

import sys

reload(sys)

sys.setdefaultencoding('utf-8')

[/code]
2.打开HTMLTestRunner.py,修改其中的第777行和第783行,将其中的编码“latin-1”修改为“utf-8”后保存,具体如下所示:
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('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('utf-8')

else:

ue = e

[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: