python3下自动化测试如何生成测试报告

下载第三方库HTMLTesteRunner

HTMLTestRunner - tungwaiyip's software

下载HTMLTestRunner.py文件,放到python文件中 Lib/site-packages的文件夹下

(或者直接使用pycharm或者pip install下载)

执行后报错1:No module named StringIO

由于下载的HTMLTestRunner.py文件属于python2版本的,在python中不适用,所以要做一些更改

解决:94行中的    import StringIO 更改为   import io

        539行中的  539行 self.outputBuffer = StringIO.StringIO()  

        更改为   self.outputBuffer = io.StringIO()

执行报错2:AttributeError: 'dict' object has no attribute 'has_key'

解决:642行中的   if not rmap.has_key(cls):   更改为   if not cls in rmap:

执行报错3:'str' object has no attribute 'decode'

解决:766行中的   uo = o.decode('latin-1')  更改为 uo = o

           772行中的   ue = e.decode('latin-1')  更改为  ue = e 

执行报错4:TypeError: can't concat bytes to str

解决:768行中的 uo = o 更改为 uo = o.decode('utf-8')

           774行中的 ue = e, 改成 ue = e.decode('utf-8')

执行报错5:TypeError: unsupported operand type(s) for >>: 'builtin_function_or_method' and 'RPCProxy'

解决:631行中的  print >>sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime)  更改为   print('\nTime Elapsed: %s' % (self.stopTime-self.startTime),file=sys.stderr)

执行报错6:TypeError: 'str' does not support the buffer interface

解决:118行中的  self.fp.write(s)  更改为  self.fp.write(bytes(s,'UTF-8'))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值