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】
各位想获取源码等教程资料的朋友请点赞 + 评论 + 收藏,三连!
三连之后我会在评论区挨个私信发给你们~