文件名称:支持python3的HTMLtestrunner(优化:带饼状图)
文件大小:26KB
文件格式:PY
更新时间:2021-02-25 14:29:10
python3
import sys,time sys.path.append('/python/venv1/demo') from HTMLTestRunner import HTMLTestRunner import unittest #指定测试用例为当下目录下的Demo中 test_dir = '/python/venv1/demo' discover = unittest.defaultTestLoader.discover(test_dir,pattern='DemoUnittest.py') if __name__ == "__main__": now = time.strftime("%Y-%m-%d %H_%M_%S") filename = "/python/venv1/report/" + now + "_result.html" fp = open(filename,"wb") runner =HTMLTestRunner(stream=fp,title='接口测试报告',description='报告如下所示:') runner.run(discover) fp.close()