def reqafter(request): filepath = request.param data = getyml.getdata(filepath) path = data['aftfixture']['path'] #获取baseurl base_url = config.getconfig()['test_env']['baseurl'] urlpath = base_url + path headers = data['aftfixture']['headers'] params = data['aftfixture']['param'] r = requests.post(url=urlpath, headers=headers, json=params) return r.status
def getrspparam(request): filepath = request.param data = getyml.getdata(filepath) path = data['fixtures']['pre'][1]['fdata']['path'] #获取baseurl base_url = config.getconfig()['test_env']['baseurl'] urlpath = base_url + path headers = data['fixtures']['pre'][1]['fdata']['headers'] params = data['fixtures']['pre'][1]['fdata']['param'] r = requests.post(url=urlpath, headers=headers, json=params) content = json.loads(r.text) userparam = content['data'] paramname = data['fixtures']['pre'][1]['fdata']['resparam'] return userparam, paramname
def getdata(request): reqparm = request.param #参数文件路径 filepath = reqparm['filep'] reqnum = reqparm['seq'] data = getyml.getdata(filepath) path = data['cdata'][reqnum]['path'] headers = data['cdata'][reqnum]['headers'] param = data['cdata'][reqnum]['param'] expected = data['cdata'][reqnum]['expected'] #获取baseurl base_url = config.getconfig()['test_env']['baseurl'] urlpath = base_url + path fdesc = data['cdata'][reqnum]['fdesc'] fname = data['cdata'][reqnum]['fname'] return urlpath, headers, param, expected
import pymysql from apiauto.conf import config from apiauto.common import log logger = log.log() #获取db配置 dbconfig = config.getconfig() user = dbconfig['test_mysql']['user'] pwd = dbconfig['test_mysql']['pwd'] ip = dbconfig['test_mysql']['ip'] database = dbconfig['test_mysql']['database'] port = int(dbconfig['test_mysql']['port']) class Mydb: def __init__(self): try: logger.info('*****数据库连接中*****') self.db = pymysql.connect(host=ip, user=user, password=pwd, database=database, port=port) self.cursor = self.db.cursor() logger.info('*****数据库连接成功*****') except Exception as e: logger.info('*****数据库连接失败*****') logger.info(e) def select(self, sql):