码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2017-03-10 15:08:31      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:add   显示乱码   tin   problem   run   tty   并保存   自己的   测试   

1.在自己的测试脚本中加入下面的代码并保存:
  1. # -.- coding:utf-8 -.-
  2. import sys
  3. reload(sys)
  4. sys.setdefaultencoding(‘utf-8‘)
2.打开HTMLTestRunner.py,修改其中的第777行和第783行,将其中的编码“latin-1”修改为“utf-8”后保存,具体如下所示:
  1. if isinstance(o,str):
  2. # TODO: some problem with ‘string_escape‘: it escape \n and mess up formating
  3. # uo = unicode(o.encode(‘string_escape‘))
  4. uo = o.decode(‘utf-8‘)
  5. else:
  6. uo = o
  7. if isinstance(e,str):
  8. # TODO: some problem with ‘string_escape‘: it escape \n and mess up formating
  9. # ue = unicode(e.encode(‘string_escape‘))
  10. ue = e.decode(‘utf-8‘)
  11. else:
  12. ue = e

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

标签:add   显示乱码   tin   problem   run   tty   并保存   自己的   测试   

原文地址:http://www.cnblogs.com/tsbc/p/6530608.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!