zoukankan      html  css  js  c++  java
  • unittest自动化使用HTMLTestRunner的中文编码问题

    1.使用unittest自动化测试框架,使用HTMLTestRunner生成测试报告,中文乱码问题!

    如图

    2.解决方法:

    第一步:先在自己的测试脚本中添加

    import sys
    reload(sys)
    sys.setdefaultencoding('utf-8')

    第二步,查找 HTMLTestRunner中的这段代码,把将其中的编码“latin-1”修改为“utf-8”后保存

    if isinstance(o,str):
                # TODO: some problem with 'string_escape': it escape 
     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 
     and mess up formating
                # ue = unicode(e.encode('string_escape'))
                #ue = e.decode('latin-1')
            else:
                ue = e

    如下,然后重新运行一下就可以解决了!

    if isinstance(o,str):
                # TODO: some problem with 'string_escape': it escape 
     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 
     and mess up formating
                # ue = unicode(e.encode('string_escape'))
                uo = o.decode('utf-8')
            else:
                ue = e
    Timer
  • 相关阅读:
    Atos cannot get symbols from dSYM of archived application
    iOS 中捕获程序崩溃日志 (2014-04-22 17:35:59)
    mysql创建索引
    maven整理项目spring配置文件加载问题
    js继承
    创建对象的方式
    js闭包
    js两种创建对象方式
    shiro-web整合
    shiro连接数据库
  • 原文地址:https://www.cnblogs.com/timer228/p/8681971.html
Copyright © 2011-2022 走看看