自动化测试报告必备第三方库
一、安装报错
> pip install HTMLTestRunner
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement HTMLTestRunner (from versions: none)
ERROR: No matching distribution found for HTMLTestRunner
二、原因分析
-
HTMLTestRunner第三方库是由Python2编写的,目前没有版本更新。
-
下载 “HTMLTestRunner.py (0.8.2)” ,将其放入Python安装路径的Lib目录下。
-
并修改HTMLTestRunner.py内容(将部分Python2的语法改为Python3语法)。
三、内容修改
094行:import StringIO 改为 import io
539行:self.outputBuffer = StringIO.StringIO() 改成 self.outputBuffer = io.StringIO()
631行:print >> sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime)
631改:print(sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime))
642行:if not rmap.has_key(cls): 改成 if not cls in rmap:
766行:uo = o.decode('latin-1') 改成 uo = e
772行:ue = e.decode('latin-1') 改成 ue = e