当前位置: 移动技术网 > IT编程>脚本编程>Python > 基于python语言的自动化测试中生成html的测试报告时HtmlTestRunner模块常见问题

基于python语言的自动化测试中生成html的测试报告时HtmlTestRunner模块常见问题

2019年06月23日  | 移动技术网IT编程  | 我要评论

断喉弩全集下载,qirexx,江淮老地方

一、导入了htmltestrunner模块,报错:no module named stringio,在python3.x中确实没有,在第94行引入的名称改成import io,539行要改成self.outputbuffer = io.bytesio(),因为写入磁盘为字节流形式,所以在119行要写城self.fp.write(s.encode()),生成报告时,bytes转化成str。

二、报错:attributeerror:‘dict’ object no attribute ‘has_key’,发现has_key的又被k掉了,所以到642行将if not rmap.has_key(cls)改成if not cls in rmap


三、报错:'str'object has no attribute 'decode',貌似是3里面对字符的操作,decode已经拿掉了。定位一下,772行 ue=e.decode('latin-1'),直接改成ue=e,另外766还有类似的uo = o.decode('latin-1')可不动先留着

四、报错:typeerror:can't concat bytes to str,bytes和str不能直接连起来,那么在778行escape(uo+ue),修改成escape(str(uo)+ue)

五、报错:pring >>sys.syderr, '\ntime elapsed: %s' % (selfl.stoptime-self.starttime)
tpyeerror: unsupported operand type(s) for >>:'buildtin_function_or_method' and 'rpcproxy' 相信这条很多刚接触3.x的人都明白,2和3是很不同,那么在3中print后面是不会跟>>这样的,所以在631行,把print的语句修改掉,原来是pring >>sys.syderr, '\ntime elapsed: %s' % (selfl.stoptime-self.starttime),可改成prin(sys.syderr, '\ntime elapsed: %s' % (selfl.stoptime-self.starttime))

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网