# -*- coding:utf-8 -*- import unittest import json from lib.ddt import ddt, data from common.handle_log import Log from common.handle_request import Request from common.handle_excel import Excel from common.handle_dir import CASE_FILE_PATH, CONFIGS_FILE_PATH from common.handle_conf import Config from common.handle_context import Context cf = Config(CONFIGS_FILE_PATH) # 配置文件对象 file = Excel(CASE_FILE_PATH, "group_login") # excel文件 data_list = file.get_cases() # 获取文件中的数据 log = Log().get_logger() # 日志对象 req = Request() # 请求对象 @ddt class Testcase(unittest.TestCase): @classmethod def setUpClass(cls): """ 初始化 :return: """ log.info("{:*^40s}".format("运营商登录开始执行用例")) @classmethod def tearDownClass(cls):
""" import jsonpath import requests from common.handle_db import db from common.handle_conf import conf from common.handle_path import DATA_DIR from common.handle_excel import Excel from common import myddt from common.handle_log import Log import os import unittest from common.handle_replacedata import replace_data sh = Excel(os.path.join(DATA_DIR, "case.xlsx"), "withdraw") sh.open() case_data = sh.read_excel() log = Log.create_log() @myddt.ddt class TestWithdraw(unittest.TestCase): @classmethod def setUpClass(cls): url = conf.get("api", "baseUrl") + "/member/login" params = { "mobile_phone": conf.get("testdata", "mobile_phone"), "pwd": conf.get("testdata", "pwd") } headers = eval(conf.get("api", "headers")) response = requests.post(url=url, json=params, headers=headers) res = response.text token = jsonpath.jsonpath(eval(res), "$..token")[0]