import os
import time

import pytest
from Config import Config

if __name__ == '__main__':
    AllureReport = Config.test_report_dir
    AllureResult = Config.test_result_dir
    TestReport = Config.test_report_parent_dir

    pytest.main()
    time.sleep(1)
    # 根据操作系统不同，将allure环境配置文件和分类文件拷贝到AllureResult报告目录下
    if os.name == 'nt':
        os.system(f"xcopy {os.path.join(TestReport, 'environment.properties')} {AllureReport} /E /I")
        os.system(f"xcopy {os.path.join(TestReport, 'categories.json')} {AllureReport} /E /I")
    else:
        os.system(f"cp -r {os.path.join(TestReport, 'environment.properties')} {AllureResult}")
        os.system(f"cp -r {os.path.join(TestReport, 'categories.json')} {AllureResult}")

    # # 产生allure报告
    os.system('allure generate ./TestReport/AllureResult -o ./TestReport/AllureReport --clean')
    # # 打开allure报告
    # os.system(f'allure open {AllureReport}')
