zoukankan      html  css  js  c++  java
  • 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 
     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

    (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 
     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 
     and mess up formating
                # ue = unicode(e.encode('string_escape'))
                #ue = e.decode('latin-1')
                ue = e.decode('utf-8')
            else:
                ue = e
  • 相关阅读:
    tomcat自启动的最简单的方法
    Eclipse引入DTD文件
    MyBatis框架之基本知识介绍
    【转】Linux系统安装Redis详细过程
    Spring MVC + Spring + MyBatis 框架整合
    Spring框架之IoC和AOP
    Mysql 时间相关
    【转】Spring事务详解
    Spring的注解问题
    关于Calendar的一些用法总结
  • 原文地址:https://www.cnblogs.com/pachongshangdexuebi/p/4720508.html
Copyright © 2011-2022 走看看