2021-07-16 22:38阅读: 125评论: 0推荐: 0

python3中用HTMLTestRunner.py报ImportError: No module named 'StringIO'如何解决

因为下载的HTMLTestRunner是Python2版本的,Python3的话要修改一下:

第94行,将import StringIO 修改为 import io

第539行,将self.outputBuffer = StringIO.StringIO() 修改为 self.outputBuffer= io.StringIO()

第642行,将if not rmap.has_key(cls): 修改为 if not cls in rmap:

第766行,将uo = o.decode(‘latin-1‘) 改为 uo = e

第773行,将ue = e.decode(‘latin-1‘) 修改为 ue = e

第631行的 print >> sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime) 或 print(sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime))

修改为 sys.stderr.write('\nTime Elapsed: %s\n' % (self.stopTime - self.startTime))

本文作者:香菜哥哥

本文链接:https://www.cnblogs.com/yizhipanghu/p/15022124.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   香菜哥哥  阅读(125)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
展开