import pytest
import os
import time

from src.framework import dingTalk
from src.framework import common

if __name__ == '__main__':
    htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute())
    pytest.main(["-v", '--reruns', '2', '--reruns-delay', '60', '--alluredir={}'.format(htmlPath), './src/testcase/', "--durations=0"])
    os.system('allure generate {} -o ./report/output --clean'.format(htmlPath))
    # os.system('allure open report/output')
    time.sleep(5)
    dingTalk.alert()
    os.system("python -m http.server 63342 -d ./report/output")

    # # 定义报告输出路径
    # htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute())
    # with(open(htmlPath, 'wb')) as fp:
    #     runner = HTMLTestRunner(
    #         stream=fp,
    #         title='AI-小麦测试报告',
    #         description='描述'
    #     )
    #     runner.run(testunit)
