# @Author : zky_wind # @Email : [email protected] # @File : test_login.py # @Software : PyCharm import json import unittest from common.excel_handler import ExcelHandler from common.logger_handler import logger from common.request_handler import RequestHandler from config.setting import config from libs import ddt # 读取数据 excel_handler = ExcelHandler(config.data_path) data = excel_handler.get_data('case_login') @ddt.ddt class TestRegister(unittest.TestCase): def setUp(self) -> None: # 初始化一个session会话 self.request = RequestHandler() # 定义一个测试结果 self.result = 'NT' def tearDown(self) -> None: # 关闭session会话 self.request.close_session() @ddt.data(*data)
# @Author : zky_wind # @Email : [email protected] # @File : test_recharge.py # @Software : PyCharm import json import unittest from common.excel_handler import ExcelHandler from common.logger_handler import logger from common.request_handler import RequestHandler from config.setting import config from libs import ddt # 读取数据 excel_handler = ExcelHandler(config.data_path) data = excel_handler.get_data('case_recharge') login_data = excel_handler.get_data('case_login')[0] @ddt.ddt class TestRegister(unittest.TestCase): def setUp(self) -> None: # 初始化一个session会话 self.request = RequestHandler() # 先登录一个账号 self.res = self.request.visit(method=login_data['method'], url=config.host + login_data['url'], json=json.loads(login_data['data']), headers=json.loads(login_data['headers'])) # 获取登录后的token self.token = "Bearer {}".format(self.res["data"]["token_info"]["token"])
# @Author : zky_wind # @Email : [email protected] # @File : test_register.py # @Software : PyCharm import json import unittest from common.excel_handler import ExcelHandler from common.logger_handler import logger from common.request_handler import RequestHandler from config.setting import config from libs import ddt # 读取数据 excel_handler = ExcelHandler(config.data_path) data = excel_handler.get_data('case_register') @ddt.ddt class TestRegister(unittest.TestCase): def setUp(self) -> None: # 初始化一个session会话 self.request = RequestHandler() # 定义一个测试结果 self.result = 'NT' def tearDown(self) -> None: # 关闭session会话 self.request.close_session() @ddt.data(*data)
# @Author : zky_wind # @Email : [email protected] # @File : test_withdraw.py # @Software : PyCharm import json import unittest from common.excel_handler import ExcelHandler from common.logger_handler import logger from common.request_handler import RequestHandler from config.setting import config from libs import ddt # 读取数据 excel_handler = ExcelHandler(config.data_path) data = excel_handler.get_data('case_withdraw') login_data = excel_handler.get_data('case_login')[0] @ddt.ddt class TestRegister(unittest.TestCase): def setUp(self) -> None: # 初始化一个session会话 self.request = RequestHandler() # 先登录一个账号 self.res = self.request.visit(method=login_data['method'], url=config.host + login_data['url'], json=json.loads(login_data['data']), headers=json.loads( login_data['headers'])) # 获取登录后的token