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
  • 相关阅读:
    程序的链接
    Graphviz 画图的一些总结
    C表达式中的汇编指令
    epoll(2) 源码分析
    epoll(2) 使用及源码分析的引子
    eventfd(2) 结合 select(2) 源码分析
    poll(2) 源码分析
    select 源码分析
    kfifo
    程序的机器级表示:寻址方式、指令及栈的运行机制
  • 原文地址:https://www.cnblogs.com/timer228/p/8681971.html
Copyright © 2011-2022 走看看