【接口自动化】json 响应断言

3/29/2023 接口自动化

# 结构化响应断言JSON XML

# Json断言

def test_hogwarts(self):
    url="https://home.testing-studio.com/categories.json"
    r = requests.get(url)
    assert r.json()['category_list']['categories'][0]['name'] == '提问区'
1
2
3
4

# Json path断言

def testhogwartsjsonpath(self)
    url="https://home.testing-studio.com/categories.json"
    r = requests.get(url)
    assert jsonpath(r.json(), '$..name')[0] == '提问区'
1
2
3
4

# jsonpath的类型

image-20230329113142196
上次更新: 2025年02月04日 13:37:36