无法断言API结果

2024-09-24 06:23:50 发布

您现在位置:Python中文网/ 问答频道 /正文

url = self.driver.current_url

notice_id = url.split('/')[-1]
time.sleep(3)

headers = {'Authorization': 'Token tokenApp="myAppToken" Token token=' + token,"Content-Type": "application/json"}

url2 = '.....' + notice_id + '&type=read'
time.sleep(3)

response = requests.get(url2, headers=headers)
print(url2)
print(notice_id)
print(response.text)
assert requests['Response'] == [{"iChannelId": 2, "sChannelName": "application web", "iCount": 1}]

我需要用python断言API结果 《邮差》的结果是:

"Response": [
  {
    "iChannelId": 2,
    "sChannelName": "application web",
    "iCount": 1
  }
],

那么,如何断言"iChannelId" == 2"sChannelName" == "application web""iCount" == 1


Tags: tokenwebidurltimeapplicationsleepnotice