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
  • 相关阅读:
    C# 模式&模式匹配
    CentOS7下安装 dotnet sdk
    PLSQL 设置
    Visual Studio Code 开发 .NetCore 插件列表
    .net core 服务生命周期
    从 Asp.Net Core 2.2 迁移到 3.0 的方案
    CSRedisCore 介绍
    Entity Framework 命令
    DataAnnotations 模型配置
    依赖注入学习(理论)
  • 原文地址:https://www.cnblogs.com/timer228/p/8681971.html
Copyright © 2011-2022 走看看