美文网首页
python 16yaml

python 16yaml

作者: 6c0fe9142f09 | 来源:发表于2018-08-13 19:24 被阅读13次

yaml是一种标记文件,我们可以使用yaml高效的保存我们的测试用例

key : value
list : 
  - value1
  - value2
  - value3
-
  url : http://118.24.3.40/api/user/login
  method : post
  detail : 登录接口
  data:
    username : niuhanyang
    passwd : aA123456
  check:
      - sign
      - userId

-
  url : http://118.24.3.40/api/user/all_stu
  method : get
  detail : 获取所有学生信息
  headers :
    Referer: http://api.nnzhp.cn/
  data:
  check:
    -
      stu_info
import yaml,json
all_case = json.dumps(yaml.load(open('login.yaml',encoding='utf-8')),ensure_ascii=False,indent=4)
print(all_case)
[
    {
        "method": "post",
        "url": "http://118.24.3.40/api/user/login",
        "detail": "登录接口",
        "data": {
            "passwd": "aA123456",
            "username": "niuhanyang"
        },
        "check": [
            "sign",
            "userId"
        ]
    },
    {
        "method": "get",
        "data": null,
        "url": "http://118.24.3.40/api/user/all_stu",
        "headers": {
            "Referer": "http://api.nnzhp.cn/"
        },
        "detail": "获取所有学生信息",
        "check": [
            "stu_info"
        ]
    }
]

相关文章

网友评论

      本文标题:python 16yaml

      本文链接:https://www.haomeiwen.com/subject/sinubftx.html