python - 无法断言 API 结果
问题描述
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结果邮递员的结果是:
“回复”: [ { “iChannelId”:2, "sChannelName": "应用网站", “iCount”:1 } ],
那么如何断言"iChannelId" == 2
and"sChannelName" == "application web"
和"iCount" == 1
?
解决方案
推荐阅读
- android - 无法在 android 上运行 react-native 新项目
- c# - 激活触摸屏键盘的派生文本框
- python - 什么是命令行争论以及它们的用途是什么?
- r - 格式化字符列中的小数位。as.numeric 擦除列中的值
- excel - Excel中的文本到列数据拆分
- c - 我的 Clang 编译器采用哪种 C 标准(ANSI、c99...)?
- c# - 在 C# 中重构 if 语句块
- mysql - mySQL80 错误 1045 (28000)::Access Denied for user@localhost (使用密码: YES)
- c# - 如何使用 LINQ 在列表中找到最大值?
- tls1.2 - 无法与 Apache pulsar 独立集群中的代理建立启用 TLS 的连接