ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

接口测试--Day7 - R

接口测试--Day7 - R

登录接口测试模块

import pytest
from interfaceAuto.unit_tools.handle_data.yaml_handler import read_yaml, write_yaml
from interfaceAuto.unit_tools.handle_data.configParse import ConfigParse
from interfaceAuto.unit_tools.sendrequests import SendRequestsconf= ConfigParse()class TestLogin:@pytest.mark.parametrize('api_info', read_yaml('./data/login.yaml'))def test_login_module(self, api_info):host = conf.get_host('host')print(api_info, host)url= host+api_info['baseInfo']['url']method = api_info['baseInfo']['method']header =  Nonedata = api_info['testcase'][0]['data']seq =SendRequests()response = seq.execute_api_request(api_name=None,url=url,method=method,header=header, case_name=None,cookie=None, file=None,data=data)results = response.json()print(f'接口返回信息: (results)')#把登录接口返回值的token写入到extract.yaml文件中login_token={}login_token['token']=results['token']write_yaml(login_token)assert results['msg'] == '登录成功,'
返回列表