Beispiel #1
0
    def test_loan_add(self, test_data):
        """
        1.访问接口,获得实际结果
        2.获得预期结果
        3.断言
        TODO:如果不加json.load,是默认获取字符串而不是JSON格式,加了json.load()相当于脱去外套,使其是JSON格式(会报AttributeError: 'str' object has no attribute 'items'错误)
        -json.loads() -json格式字符串转化为字典
        -json.dump() -字典转化为json格式字符串
        """
        """使用正则表达式匹配excel.loan中的 #memberId_recharge# 、、#wrong_memberId_recharge# ,然后映射Context类对应属性中的值进行替换 """
        test_data["json"] = replace_label(test_data["json"])

        print("正在执行第{}条用例,测试的内容是:{}".format(test_data["case_id"],
                                            test_data["case_name"]))
        """
        #假设res()是接口函数,使用mock去模拟接口返回来的数据,为了在接口还没开发好跑通自己的测试逻辑
        res = Mock(return_value = test_data["expected_result"])
        try:
            self.assertEqual(test_data["expected_result"],res())
            test_result = "pass"  # 用例测试通过
        """
        """访问"新增项目"接口"""
        res = RequestsHandle().visit(test_data["method"],
                                     config.host + test_data["url"],
                                     json=json.loads(test_data["json"]),
                                     headers=self.headers)
        """断言时需进行异常处理"""
        try:
            """可采用for循环遍历预期结果的值,进行多个断言"""
            for k, v in json.loads(test_data["expected_result"]).items():
                if k in res:
                    self.assertEqual(v, res[k])
            test_result = "pass"  # 用例测试通过

        except AssertionError as e:
            print("断言失败,错误信息如下:{}".format(e))
            test_result = "fail"  # 用例测试失败
            logger.error(e)  # 将错误信息记录到日志文件中
            raise AssertionError  #手动抛出异常,不然会测试通过

        finally:
            column_actualResult = excel_handler.sheet_header(
                config.read_yaml()["Excel_handler"]["sheet_loan_add"]).index(
                    "actual_result")  #获取"loan_add"表单标题中"actual_result"索引值
            ExcelHandler.sheet_writeCell(
                config.data_path(),
                config.read_yaml()["Excel_handler"]["sheet_loan_add"],
                test_data["case_id"] + 1, column_actualResult + 1,
                str(res))  # 向actual_result写值

            column_testResult = excel_handler.sheet_header(
                config.read_yaml()["Excel_handler"]["sheet_loan_add"]).index(
                    "test_result")  #获取"loan_add"表单标题中"test_result"索引值
            ExcelHandler.sheet_writeCell(
                config.data_path(),
                config.read_yaml()["Excel_handler"]["sheet_loan_add"],
                test_data["case_id"] + 1, column_testResult + 1,
                test_result)  # 向test_result填写测试结果,"pass"or"fail"
Beispiel #2
0
def login():
    """登录获取token,访问充值接口"""
    res_recharge=RequestsHandle().visit("post",
                               config.host + "/member/login",
                               json=config.read_yaml()["User_RechargeTest"],
                               headers={"X-Lemonban-Media-Type":"lemonban.v2"})

    """登录获取token,访问提现接口"""
    res_withdraw=RequestsHandle().visit("post",
                               config.host + "/member/login",
                               json=config.read_yaml()["User_WithdrawTest"],
                               headers={"X-Lemonban-Media-Type":"lemonban.v2"})


    return {"res_recharge":res_recharge,"res_withdraw":res_withdraw}
Beispiel #3
0
    def loan_id(self):
        self.db = DbHandler(host=config.read_yaml()["Database"]["host"], port=config.read_yaml()["Database"]["port"],
                       user=config.read_yaml()["Database"]["user"], password=config.read_yaml()["Database"]["password"],
                       charset=config.read_yaml()["Database"]["charset"], database=config.read_yaml()["Database"]["database"])

        sql = self.db.query("select * from loan where status=2 and full_time is null limit 100;")
        loan_id = sql["id"]
        self.db.close()
        return loan_id
 def __init__(self,
              log_name=config.read_yaml()["Logger_handler"]["log_name"],
              filename=config.read_yaml()["Logger_handler"]["filename"],
              HandlerLevel="DEBUG",
              StreamHandler="DEBUG"):
     """在父类创建实例,并且初始化logger收集器"""
     super().__init__(log_name)
     """设置级别"""
     self.setLevel("DEBUG")
     """设置handler格式"""
     fmt = logging.Formatter(
         "%(filename)s-%(lineno)d-%(levelname)s-%(name)s-%(message)s-%(asctime)s"
     )
     """初始化处理器/设置处理器级别/设置处理器格式"""
     if log_name:
         handler = logging.FileHandler(filename)  #file文件输出
         handler.setLevel(HandlerLevel)
         handler.setFormatter(fmt)
         self.addHandler(handler)
     console_handler = logging.StreamHandler()  #控制台输出
     console_handler.setLevel(StreamHandler)
     console_handler.setFormatter(fmt)
     self.addHandler(console_handler)
     """"""
    def setUp(self) -> None:  #前置条件
        """ 连接数据库"""
        self.db = DbHandler(
            host=config.read_yaml()["Database"]["host"],
            port=config.read_yaml()["Database"]["port"],
            user=config.read_yaml()["Database"]["user"],
            password=config.read_yaml()["Database"]["password"],
            charset=config.read_yaml()["Database"]["charset"],
            database=config.read_yaml()["Database"]["database"])
        """投资和登录的用例关联(或者用例依赖),而且充值、新增项目、投资使用同一测试账号"""
        """获取登录时生成的token"""
        token = Context.token_recharge
        """将投资账号的token添加进headers的字典中"""
        headers_dict = {"X-Lemonban-Media-Type": "lemonban.v2"}
        headers_dict["Authorization"] = token
        self.headers = headers_dict

        print("正在准备测试数据")
Beispiel #6
0
    def test_register(self,test_data):
        """
        1.访问接口,获得实际结果
        2.获得预期结果
        3.断言
        TODO:如果不加json.load,是默认获取字符串而不是JSON格式,加了json.load()相当于脱去外套,使其是JSON格式(会报AttributeError: 'str' object has no attribute 'items'错误)
        -json.loads() -json格式字符串转化为字典
        -json.dump() -字典转化为json格式字符串
        """

        """对已存在的手机号码获取测试"""
        if "#exist_phone#" in test_data["json"]:
            """查询数据库,如果数据库中存在该手机号,就直接使用这个号码"""
            exist_phone = self.db.query("select * from member limit 1;") #TODO:某些相同的手机号码在数据库中存在多条,无法通过测试
            if exist_phone:
                """替换excel中的#exist_phone#"""
                test_data["json"] =test_data["json"].replace("#exist_phone#",exist_phone["mobile_phone"])
            else:
                """
                如果数据库为空,则手动注册,然后对注册好的用户进行已存在用例测试
                """
                pass

        """创建新的手机号码测试"""
        if "#new_phone#" in test_data["json"]:

            while True:
                """生成新的手机号码并且到数据库里去查询,如果存在就再生成一次,直到生成个数据库不存在的号码为止"""
                new_phone=generate_mobile()  #TODO:某些手机号码格式不正确无法通过测试
                new_mobile = self.db.query("select * from member where mobile_phone=%s;",args=[new_phone])
                if not new_mobile:
                    break

            """替换excel中的#new_phone#"""
            test_data["json"] = test_data["json"].replace("#new_phone#",new_phone)

        print("正在执行第{}条用例,测试的内容是:{}".format(test_data["case_id"], test_data["case_name"]))

        """
        #假设res()是接口函数,使用mock去模拟接口返回来的数据,为了在接口还没开发好跑通自己的测试逻辑
        res = Mock(return_value = test_data["expected_result"])
        try:
            self.assertEqual(test_data["expected_result"],res())
            test_result = "pass"  # 用例测试通过
        """

        res = RequestsHandle().visit(test_data["method"],
                                     config.host + test_data["url"],
                                     json=json.loads(test_data["json"]),
                                     headers=json.loads(test_data["headers"]))

        """断言时需进行异常处理"""
        try:
            """可采用for循环遍历预期结果的值,进行多个断言"""
            for k,v in json.loads(test_data["expected_result"]).items():
                if k in res:
                    self.assertEqual(v,res[k])
            test_result = "pass"  # 用例测试通过

        except AssertionError as e:
            print("断言失败,错误信息如下:{}".format(e))
            test_result = "fail"  # 用例测试失败
            logger.error(e) # 将错误信息记录到日志文件中
            raise AssertionError #手动抛出异常,不然会测试通过

        finally:
            column_actualResult=excel_handler.sheet_header(config.read_yaml()["Excel_handler"]["sheet_register"]).index("actual_result") #获取"register"表单标题中"actual_result"索引值
            ExcelHandler.sheet_writeCell(config.data_path(),
                                         config.read_yaml()["Excel_handler"]["sheet_register"],
                                         test_data["case_id"]+1,
                                         column_actualResult+1,
                                         str(res))  # 向actual_result写值

            column_testResult=excel_handler.sheet_header(config.read_yaml()["Excel_handler"]["sheet_register"]).index("test_result") #获取"register"表单标题中"test_result"索引值
            ExcelHandler.sheet_writeCell(config.data_path(),
                                         config.read_yaml()["Excel_handler"]["sheet_register"],
                                         test_data["case_id"]+1,
                                         column_testResult+1,
                                         test_result)  # 向test_result填写测试结果,"pass"or"fail"
Beispiel #7
0
 def setUp(self) -> None: #前置条件
     """ 连接数据库"""
     self.db = DbHandler(host=config.read_yaml()["Database"]["host"], port=config.read_yaml()["Database"]["port"],
                    user=config.read_yaml()["Database"]["user"], password=config.read_yaml()["Database"]["password"],
                    charset=config.read_yaml()["Database"]["charset"], database=config.read_yaml()["Database"]["database"])
     print("正在准备测试数据")
Beispiel #8
0
from mock import Mock
from libs import ddt
from common.Excel_handler import ExcelHandler
from common.Request_handler import RequestsHandle
from common.Logger_handler import LoggerHandler
from config.setting import config  #小技巧:直接导入实例对象,避免路径被修改导致报错
from common.db_handler import DbHandler
from middleware.helper import generate_mobile

"""初始化日志处理器"""
logger=LoggerHandler()

"""读取"注册"表单中的数据"""
excel_handler = ExcelHandler(config.data_path())
data = excel_handler.sheet_readAll(config.read_yaml()["Excel_handler"]["sheet_register"])  # 从yaml中读取"注册"表单名称

@ddt.ddt
class TestRegister(unittest.TestCase):
    def setUp(self) -> None: #前置条件
        """ 连接数据库"""
        self.db = DbHandler(host=config.read_yaml()["Database"]["host"], port=config.read_yaml()["Database"]["port"],
                       user=config.read_yaml()["Database"]["user"], password=config.read_yaml()["Database"]["password"],
                       charset=config.read_yaml()["Database"]["charset"], database=config.read_yaml()["Database"]["database"])
        print("正在准备测试数据")

    def tearDown(self) -> None: #后置条件
        """ 关闭数据库游标和连接"""
        self.db.close()
        print("测试用例执行完毕")
Beispiel #9
0
    def query(self, sql, args=None, one=True):
        """args 参数用来传递参数,填%s的坑 , 例如:select * from member limit 1 where mobile_phone = %s;"""
        """查询语句"""
        self.cursor.execute(sql, args)

        #TODO:提交事务,同步数据
        self.conn.commit()
        """获取结果"""
        if one:
            res = self.cursor.fetchone()
        else:
            res = self.cursor.fetchall()
        return res

    def close(self):
        self.cursor.close()  #关闭游标
        self.conn.close()  #关闭连接


if __name__ == "__main__":
    db_data = config.read_yaml()  #从yaml文件中读取相关配置参数
    db = DbHandler(host=db_data["Database"]["host"],
                   port=db_data["Database"]["port"],
                   user=db_data["Database"]["user"],
                   password=db_data["Database"]["password"],
                   charset=db_data["Database"]["charset"],
                   database=db_data["Database"]["database"])
    print(
        db.query("select * from member where mobile_phone=%s and id=%s;",
                 args=["15917169660", 900476]))
Beispiel #10
0
import json

from mock import Mock
from decimal import Decimal
from common.db_handler import DbHandler
from libs import ddt
from common.Excel_handler import ExcelHandler
from common.Request_handler import RequestsHandle
from common.Logger_handler import LoggerHandler
from config.setting import config  #小技巧:直接导入实例对象,避免路径被修改导致报错
from middleware.helper import Context, replace_label
"""初始化日志处理器"""
logger = LoggerHandler()
"""读取"新增项目"表单中的数据"""
excel_handler = ExcelHandler(config.data_path())
data = excel_handler.sheet_readAll(config.read_yaml()["Excel_handler"]
                                   ["sheet_loan_add"])  # 从yaml中读取"新增项目"表单名称


@ddt.ddt
class TestLoanAdd(unittest.TestCase):
    def setUp(self) -> None:  #前置条件
        """ 连接数据库"""
        self.db = DbHandler(
            host=config.read_yaml()["Database"]["host"],
            port=config.read_yaml()["Database"]["port"],
            user=config.read_yaml()["Database"]["user"],
            password=config.read_yaml()["Database"]["password"],
            charset=config.read_yaml()["Database"]["charset"],
            database=config.read_yaml()["Database"]["database"])
        """新增项目和登录的用例关联(或者用例依赖)"""
        # 充值、新增项目、投资使用同一测试账号
    def test_recharge(self, test_data):
        """
        1.访问接口,获得实际结果
        2.获得预期结果
        3.断言
        TODO:如果不加json.load,是默认获取字符串而不是JSON格式,加了json.load()相当于脱去外套,使其是JSON格式(会报AttributeError: 'str' object has no attribute 'items'错误)
        -json.loads() -json格式字符串转化为字典
        -json.dump() -字典转化为json格式字符串
        """
        """查询数据库,查询登录后的余额"""
        user = self.db.query("select * from member where id=%s;",
                             args=[self.member_id])
        before_money = user["leave_amount"]
        """使用正则表达式匹配excel.recharge中的 #memberId_recharge# 、、#wrong_memberId_recharge# ,然后映射Context类对应属性中的值进行替换 """
        test_data["json"] = replace_label(test_data["json"])

        print("正在执行第{}条用例,测试的内容是:{}".format(test_data["case_id"],
                                            test_data["case_name"]))
        """
        #假设res()是接口函数,使用mock去模拟接口返回来的数据,为了在接口还没开发好跑通自己的测试逻辑
        res = Mock(return_value = test_data["expected_result"])
        try:
            self.assertEqual(test_data["expected_result"],res())
            test_result = "pass"  # 用例测试通过
        """
        """访问"充值"接口"""
        res = RequestsHandle().visit(test_data["method"],
                                     config.host + test_data["url"],
                                     json=json.loads(test_data["json"]),
                                     headers=self.headers)
        """断言时需进行异常处理"""
        try:
            """可采用for循环遍历预期结果的值,进行多个断言"""
            for k, v in json.loads(test_data["expected_result"]).items():
                if k in res:
                    self.assertEqual(v, res[k])

            # """查看数据库结果,登录后的余额 + 充值金额 = 充值后的余额"""
            if res["code"] == 0:
                money = json.loads(test_data["json"])["amount"]
                """查询数据库,查询充值后的余额"""
                after_user = self.db.query("select * from member where id=%s;",
                                           args=[self.member_id])
                after_money = after_user["leave_amount"]

                try:
                    """断言 登录后的余额 + 充值金额 是否等于 充值后的余额"""
                    self.assertEqual(
                        Decimal(str(money)) + Decimal(str(before_money)),
                        Decimal(str(after_money)))
                    """用例测试通过"""
                    test_result = "pass"

                except AssertionError as e:
                    print("断言失败,错误信息如下:{}".format(e))
                    test_result = "fail"  # 用例测试失败
                    logger.error(e)  # 将错误信息记录到日志文件中
                    raise AssertionError  # 手动抛出异常,不然会测试通过

            if res["code"] != 0:
                """用例测试通过"""
                test_result = "pass"

        except AssertionError as e:
            print("断言失败,错误信息如下:{}".format(e))
            test_result = "fail"  # 用例测试失败
            logger.error(e)  # 将错误信息记录到日志文件中
            raise AssertionError  #手动抛出异常,不然会测试通过

        finally:
            column_actualResult = excel_handler.sheet_header(
                config.read_yaml()["Excel_handler"]["sheet_recharge"]).index(
                    "actual_result")  #获取"recharge"表单标题中"actual_result"索引值
            ExcelHandler.sheet_writeCell(
                config.data_path(),
                config.read_yaml()["Excel_handler"]["sheet_recharge"],
                test_data["case_id"] + 1, column_actualResult + 1,
                str(res))  # 向actual_result写值

            column_testResult = excel_handler.sheet_header(
                config.read_yaml()["Excel_handler"]["sheet_recharge"]).index(
                    "test_result")  #获取"recharge"表单标题中"test_result"索引值
            ExcelHandler.sheet_writeCell(
                config.data_path(),
                config.read_yaml()["Excel_handler"]["sheet_recharge"],
                test_data["case_id"] + 1, column_testResult + 1,
                test_result)  # 向test_result填写测试结果,"pass"or"fail"
from mock import Mock
from decimal import Decimal
from common.db_handler import DbHandler
from libs import ddt
from common.Excel_handler import ExcelHandler
from common.Request_handler import RequestsHandle
from common.Logger_handler import LoggerHandler
from config.setting import config  #小技巧:直接导入实例对象,避免路径被修改导致报错
from middleware.helper import Context, replace_label
"""初始化日志处理器"""
logger = LoggerHandler()
"""读取"充值"表单中的数据"""
excel_handler = ExcelHandler(config.data_path())
data = excel_handler.sheet_readAll(
    config.read_yaml()["Excel_handler"]["sheet_recharge"])  # 从yaml中读取"充值"表单名称


@ddt.ddt
class TestRecharge(unittest.TestCase):
    def setUp(self) -> None:  #前置条件
        """ 连接数据库"""
        self.db = DbHandler(
            host=config.read_yaml()["Database"]["host"],
            port=config.read_yaml()["Database"]["port"],
            user=config.read_yaml()["Database"]["user"],
            password=config.read_yaml()["Database"]["password"],
            charset=config.read_yaml()["Database"]["charset"],
            database=config.read_yaml()["Database"]["database"])
        """充值和登录的用例关联(或者用例依赖)"""
        # 充值、新增项目、投资使用同一测试账号
    def test_invest(self, test_data):
        """
        1.访问接口,获得实际结果
        2.获得预期结果
        3.断言
        TODO:如果不加json.load,是默认获取字符串而不是JSON格式,加了json.load()相当于脱去外套,使其是JSON格式(会报AttributeError: 'str' object has no attribute 'items'错误)
        -json.loads() -json格式字符串转化为字典
        -json.dump() -字典转化为json格式字符串
        """
        """使用正则表达式匹配excel.invest中的 #memberId_recharge# 、#loan_id# 、#wrong_memberId_recharge# ,然后映射Context类对应属性中的值进行替换 """
        test_data["json"] = replace_label(test_data["json"])
        """
        替换excel.invest中的 *above_balance*
        
        测试用例:投资金额大于用户余额
        用例会出现两种情况:
        - 投资金额大于用户余额,同时大于项目可投金额,会报错 "该标可投金额不足,可投金额:xxxx",测试OK
        - 投资金额大于用户余额,但是小于等于项目可投金额,仍然可以投资成功,资产负债,测试OK
        """
        """查询数据库,查询登录后的余额"""
        user = self.db.query("select * from member where id=%s;",
                             args=[Context.memberId_recharge])
        before_money = user["leave_amount"]

        if "*above_balance*" in test_data["json"]:
            """如果登录后的余额为负数,转化为正数"""
            if before_money < 0:
                before_money = before_money * (-1)
            """将登录后的余额进行取整、转化为能被100整除(目的是使投资金额必须为能被100整除的整数),再加100使其投资金额大于账户余额"""
            test_data["json"] = test_data["json"].replace(
                "*above_balance*",
                str(int(before_money) - (int(before_money) % 100) +
                    100))  # 注意将ID转化为字符串

        print("正在执行第{}条用例,测试的内容是:{}".format(test_data["case_id"],
                                            test_data["case_name"]))
        """
        #假设res()是接口函数,使用mock去模拟接口返回来的数据,为了在接口还没开发好跑通自己的测试逻辑
        res = Mock(return_value = test_data["expected_result"])
        try:
            self.assertEqual(test_data["expected_result"],res())
            test_result = "pass"  # 用例测试通过
        """
        """访问"投资"接口"""
        res = RequestsHandle().visit(test_data["method"],
                                     config.host + test_data["url"],
                                     json=json.loads(test_data["json"]),
                                     headers=self.headers)
        """断言时需进行异常处理"""
        try:
            """可采用for循环遍历预期结果的值,进行多个断言"""
            for k, v in json.loads(test_data["expected_result"]).items():
                if k in res:
                    self.assertEqual(v, res[k])

            # """查看数据库结果,登录后的余额 - 投资金额 = 投资后的余额"""
            if res["code"] == 0:
                money = json.loads(test_data["json"])["amount"]
                """查询数据库,查询投资后的余额"""
                after_user = self.db.query("select * from member where id=%s;",
                                           args=[Context.memberId_recharge])
                after_money = after_user["leave_amount"]

                try:
                    """断言 登录后的余额 - 投资金额 是否等于 投资后的余额"""
                    self.assertEqual(
                        Decimal(str(before_money)) - Decimal(str(money)),
                        Decimal(str(after_money)))
                    """用例测试通过"""
                    test_result = "pass"

                except AssertionError as e:
                    print("断言失败,错误信息如下:{}".format(e))
                    test_result = "fail"  # 用例测试失败
                    logger.error(e)  # 将错误信息记录到日志文件中
                    raise AssertionError  # 手动抛出异常,不然会测试通过

            if res["code"] != 0:
                """用例测试通过"""
                test_result = "pass"

        except AssertionError as e:
            print("断言失败,错误信息如下:{}".format(e))
            test_result = "fail"  # 用例测试失败
            logger.error(e)  # 将错误信息记录到日志文件中
            raise AssertionError  #手动抛出异常,不然会测试通过

        finally:
            column_actualResult = excel_handler.sheet_header(
                config.read_yaml()["Excel_handler"]["sheet_invest"]).index(
                    "actual_result")  #获取"invest"表单标题中"actual_result"索引值
            ExcelHandler.sheet_writeCell(
                config.data_path(),
                config.read_yaml()["Excel_handler"]["sheet_invest"],
                test_data["case_id"] + 1, column_actualResult + 1,
                str(res))  # 向actual_result写值

            column_testResult = excel_handler.sheet_header(
                config.read_yaml()["Excel_handler"]["sheet_invest"]).index(
                    "test_result")  #获取"invest"表单标题中"test_result"索引值
            ExcelHandler.sheet_writeCell(
                config.data_path(),
                config.read_yaml()["Excel_handler"]["sheet_invest"],
                test_data["case_id"] + 1, column_testResult + 1,
                test_result)  # 向test_result填写测试结果,"pass"or"fail"
from mock import Mock
from decimal import Decimal
from common.db_handler import DbHandler
from libs import ddt
from common.Excel_handler import ExcelHandler
from common.Request_handler import RequestsHandle
from common.Logger_handler import LoggerHandler
from config.setting import config  #小技巧:直接导入实例对象,避免路径被修改导致报错
from middleware.helper import Context, replace_label
"""初始化日志处理器"""
logger = LoggerHandler()
"""读取"投资"表单中的数据"""
excel_handler = ExcelHandler(config.data_path())
data = excel_handler.sheet_readAll(
    config.read_yaml()["Excel_handler"]["sheet_invest"])  # 从yaml中读取"投资"表单名称


@ddt.ddt
class TestInvest(unittest.TestCase):
    def setUp(self) -> None:  #前置条件
        """ 连接数据库"""
        self.db = DbHandler(
            host=config.read_yaml()["Database"]["host"],
            port=config.read_yaml()["Database"]["port"],
            user=config.read_yaml()["Database"]["user"],
            password=config.read_yaml()["Database"]["password"],
            charset=config.read_yaml()["Database"]["charset"],
            database=config.read_yaml()["Database"]["database"])
        """投资和登录的用例关联(或者用例依赖),而且充值、新增项目、投资使用同一测试账号"""
        """获取登录时生成的token"""
Beispiel #15
0
import unittest
import json

from mock import Mock

from libs import ddt
from common.Excel_handler import ExcelHandler
from common.Request_handler import RequestsHandle
from common.Logger_handler import LoggerHandler
from config.setting import config  #小技巧:直接导入实例对象,避免路径被修改导致报错
"""初始化日志处理器"""
logger = LoggerHandler()
"""读取"登录"表单中的数据"""
excel_handler = ExcelHandler(config.data_path())
data = excel_handler.sheet_readAll(
    config.read_yaml()["Excel_handler"]["sheet_login"])  # 从yaml中读取"登录"表单名称


@ddt.ddt
class TestLogin(unittest.TestCase):
    def setUp(self) -> None:  #前置条件
        print("正在准备测试数据")

    def tearDown(self) -> None:  #后置条件
        print("测试用例执行完毕")

    """将 *data 当中的一组测试数据赋值到 data 这个参数"""

    @ddt.data(*data)
    def test_login(self, test_data):
        """