#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2022/12/8 21:52
# @Author  : Shitou
# @FileName: run.py
# @Software: PyCharm


# import sys
# import os
# curPath = os.path.abspath(os.path.dirname(__file__))
# rootPath = os.path.split(curPath)[0]
# sys.path.append(rootPath)

import unittest
from unittestreport import TestRunner

from common.handle_config import conf

from tools.function import runner_test
from common.handle_path import TestCase_Path, Report_Path
# 登陆
from testcase.test_01_login import TestLogin
# 新增院系、新增专业、新增学年学期、
from testcase.test_02_system_management import Test01Department, Test02Specialty, Test03Year
# 新增教师、新增班级、新增课程、新增学生、
from testcase.test_03_teaching_affairs import Test01Teacher, Test02Class, Test03Course, Test04Student
# 新增计划、发布计划、新增项目、发布项目、
# from testcase.test_04_Internship_preparation import Test01addInternshipPlan, Test04publishInternshipPlan, \
#     # Test03addInternshipProject, Test04publishInternshipProject
# 学生查看实习、学生报名、
from testcase.test_05_student_practice import Test01SelectAllPractice, Test02StudentApply
# 查看报名审核、报名审核-学校端-进行审核、报名审核-hr端-待审核列表查看(实习申请列表)、  报名审核-hr端-进行审核
# from testcase.test_06_internship_manage import Test01SelectApplyAuditList, Test02SchoolAudit

""" 
执行所有用例
"""
# 创建测试套件
suite_all = unittest.TestSuite()
# 加载用例
# ---创建加载器
load = unittest.TestLoader()
# ---用例放到加载器
suite_all.addTest(load.discover(TestCase_Path))

"""
# 执行单独模块用例
# """
a1 = unittest.TestLoader().loadTestsFromTestCase(TestLogin)
a2 = unittest.TestLoader().loadTestsFromTestCase(Test01Department)
a3 = unittest.TestLoader().loadTestsFromTestCase(Test02Specialty)
a4 = unittest.TestLoader().loadTestsFromTestCase(Test03Year)
a5 = unittest.TestLoader().loadTestsFromTestCase(Test02Class)
a6 = unittest.TestLoader().loadTestsFromTestCase(Test04Student)
# bbbbbb = unittest.TestLoader().loadTestsFromTestCase(Test02SchoolAudit)
# cccc = unittest.TestLoader().loadTestsFromTestCase(Test01addInternshipPlan)
suite = unittest.TestSuite([a1, a2, a3, a4, a5, a6])
# suite_a = unittest.TestSuite([cccc])

runner_test(suite_all)  # 执行

# runner_test(suite_a)  # 执行

# input_case = input("请输入需要执行的用例:")
# try:
#     if input_case in "全部":
#         suite = suite_all
#     elif input_case in "教师":
#         suite = suite_teacher
#     runner_test(suite)  # 执行
#
# except NameError as a:
#     print("输入错误")
# else:
#     print("执行完毕,请确认")
# # 运行文件
# runner = TestRunner(suite=suite_all,
#                     filename=conf.get("report", "filename"),
#                     report_dir=Report_Path,
#                     title=conf.get("report", "title"),
#                     tester=conf.get("report", "tester"),
#                     desc=conf.get("report", "desc"),
#                     templates=conf.getint("report", "templates")
#                     )
# # runner.run()
# # 执行失败重新运行机制
# runner.rerun_run(count=2, interval=0.2)