加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

Python3 Selenium自动化web测试 ==>FAQ:Unittest测试报告生

发布时间:2020-12-20 11:02:26 所属栏目:Python 来源:网络整理
导读:测试代码,虽然有点笨重,以后再修改: if __name__ == ‘ __main__ ‘ : report = os.path.join( ‘ D:/Python36/report/report.html ‘ ) suite1 = unittest.TestSuite() suite1.addTests([TestStringMethods( ‘ test_split ‘ ),TestStringMethods( ‘ t

测试代码,虽然有点笨重,以后再修改:

if __name__ == __main__:
    report = os.path.join(D:/Python36/report/report.html)
    suite1 = unittest.TestSuite()
    suite1.addTests([TestStringMethods(test_split),TestStringMethods(test_isupper),TestStringMethods(test_upper)])
    with open(report,wb) as f:
        runner2 = HTMLTestRunner(stream=f,title=Test Result,description=operator:admin,verbosity=2)
        runner2.run(suite1)
        print(report is done)
    report_path = os.path.dirname(report)
#os.chdir() 方法用于改变当前工作目录到指定的路径。
    os.chdir(report_path)
    stamp = datetime.datetime.strftime(datetime.datetime.now(),"%Y-%m-%d-%H-%M-%S")
    report_new_name = report+ stamp +.html
    os.rename(report.html,report_new_name)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读