• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

pytest 接口测试框架学习

武飞扬头像
bug捕手
帮助3

  1.  
    import requests
  2.  
     
  3.  
    class TestDemo:
  4.  
    def test_get(self):
  5.  
    r = requests.get("https://www.百度.com/")
  6.  
    print(r.status_code)
  7.  
    assert r.status_code == 200
  8.  
     
  9.  
    def test_query(self):
  10.  
    payload = {
  11.  
    "level": 1,
  12.  
    "name": "xuefeifei"
  13.  
    }
  14.  
    r = requests.get("https://httpbin.testing-studio.com/get", params=payload)
  15.  
    print(r.text)
  16.  
    assert r.status_code == 200
  17.  
     
  18.  
    def test_post_form(self):
  19.  
    payload = {
  20.  
    "level": 1,
  21.  
    "name": "xuefeifei"
  22.  
    }
  23.  
    r = requests.post("https://httpbin.testing-studio.com/post", data=payload)
  24.  
    print(r.text)
  25.  
    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】

学新通

学新通

各位想获取源码等教程资料的朋友请点赞 评论 收藏,三连!

三连之后我会在评论区挨个私信发给你们~

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfgibac
系列文章
更多 icon
同类精品
更多 icon
继续加载