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