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
  • 相关阅读:
    vue 之 vuex
    vue中this.$router.push() 传参
    ES6新特性
    css优先级
    创建第一个vue工程
    对Vue.js的认知
    前端的认知与见解
    Web前端常见问题
    数据库如何进行索引优化
    Python FAQ
  • 原文地址:https://www.cnblogs.com/timer228/p/8681971.html
Copyright © 2011-2022 走看看