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))

posted @ 2021-07-16 22:38  香菜哥哥  阅读(119)  评论(0编辑  收藏  举报