Python 3.6版本中实现 HTMLTestRunner输出时”fp=file(filename,'wb')“报错
原错误代码:
if __name__=='__main__': suite=unittest.makeSuite(WidgetTestCase) filename='D:\\myreport.html' fp=file(filename,'wb') runner=HTMLTestRunner.HTMLTestRunner(fp,title=u'my unit test',description=u'This is a report test') runner.run(suite)
改成以下格式就正常了:
if __name__ == '__main__':
filename = './myAppiumLog.html'
with open(filename, 'wb') as f:
# 使用HTMLTestRunner配置参数,输出报告路径、报告标题、描述
runner = HTMLTestRunner.HTMLTestRunner(
stream=f,
title='Report_title',
description='Report_description'
)