01 测试登录接口
import json
import requests
import pytest
from jsonpath import jsonpath
from common.excel import read_excel
from setting.path import case_path
# 从 Excel 当中读取出来所有的用例数据
items = read_excel(case_path, 'adminLogin')
@pytest.mark.parametrize('item', items)
def test_login_02(item):
url = item.get("url")
method = item.get("method")
params = item.get("params", '{}')
headers = item.get("headers", '{}')
body = item.get("json", '{}')
expected = item.get("expected")
# # 把excel当中字符串转成字典
# if params is not None:
# params_dict = json.loads(params)
# if headers is not None:
# headers_dict = json.loads(headers)
# body_dict = json.loads(body)
# 把excel当中字符串转成字典
params_dict = json.loads(params)
headers_dict = json.loads(headers)
body_dict = json.loads(body)
# 2、发起请求,得到响应
response = requests.request(url=url,
method=method,