HTMLTestRunner.py模块从python2转python3
用python3会各种报错。主要修改如下几点:
第100行,将import StringIO修改成import io
第527行,将self.outputBuffer = StringIO.StringIO()修改成self.outputBuffer = io.StringIO()
第648行,将print >> sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime)修改成print(sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime))
第658行,将if not rmap.has_key(cls):修改成if not cls in rmap:
第781行,将uo = o.decode('latin-1')修改成uo = o.encode('utf-8').decode('utf-8')
第788行,将ue = e.decode('latin-1')修改成ue = e.encode('utf-8').decode('utf-8')
输出报告中文乱码问题
打开写入文件时设置编码
outfile = open(filename, 'w', encoding='utf-8')
原文件(python2版本)下载地址:http://tungwaiyip.info/software/HTMLTestRunner.html


浙公网安备 33010602011771号