import requests
class TestDemo:
def test_get(self):
r = requests.get("https://www.baidu.com/")
print(r.status_code)
assert r.status_code == 200
def test_query(self):
payload = {
"level": 1,
"name": "xuefeifei"
}
r = requests.get("https://httpbin.testing-studio.com/get", params=payload)
print(r.text)
assert r.status_code == 200
def test_post_form(self):
payload = {
"level": 1,
"name": "xuefeifei"
}
r = requests.post("https://httpbin.testing-studio.com/post", data=payload)
print(r.text)
assert r.status_code == 200def test_post_json(self):<br> payload = {<br> "level": 1,<br> "name": "xuefeifei"<br> }<br> r = requests.post("https://httpbin.testing-studio.com/post", json=payload)<br> print(r.json())<br> assert r.json()["json"]["level"] == 1
使用pycharm
新建一个project, 进入preferences,添加 pytest,和requests
资料获取方法
【留言777】
各位想获取源码等教程资料的朋友请点赞 + 评论 + 收藏,三连!文章来源:https://www.toymoban.com/news/detail-612672.html
三连之后我会在评论区挨个私信发给你们~文章来源地址https://www.toymoban.com/news/detail-612672.html
到了这里,关于pytest 接口测试框架学习的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!