• Python新数据源类型Yaml


    Yaml作为一种新的数据源,类似XML,与excel同等用途都可以作为测试框架的数据源

    下载来源:     

    如OS是windows7 64bit则在 https://pypi.python.org/pypi/PyYAML/ 下载【PyYAML-3.12.win-amd64-py3.5.exe (md5)】直接安装。

    或者windows命令行下使用命令:pip install pyyaml

    实践内容如下

    example.yaml文件内容:

    postbody: <--无值,但有子项[LoginA,Login及子项]的则等同于增加{} LoginA: <--无值,无子项,yaml.load后值为null,与Login属兄弟关系 Login: <--无值,有子项,值为子项组成的列表 Type: LV <--有值,无子项,生成父项值的列表中的字典元素"Type":"LV" Name:
    15801570690 Pwd: 123456 PwdA: <--无值,无子项,yaml.load后值为null OAuthType: 1
    Python编译器输出:

    "
    postbody": { "Login": { "Name": 15801570690, "OAuthType": 1, "Pwd": 123456, "PwdA": null, "Type": "LV" }, "LoginA": null }

     如果有参数带‘-’会被处理成什么形式:

    postbody:               "postbody": {
      TInfo:                    "Login": {
       U2: ttt                      "Name": 15801570690,
      LoginA:                       "OAuthType": 1,
      Login:                    },
       Type: LV                 "LoginA": null,
       Name: 15801570690        "TInfo": {
       Pwd: 123456                  "U2": "ttt"
                                }
                            }
    
    子项带有‘-’,父项的值立刻变成列表格式
    postbody:                "postbody": [
    - TInfo:                    {
       U2: ttt                      "Login": {
      LoginA:                           "Name": 15801570690,
      Login:                            "OAuthType": 1,
       Type: LV                     },
       Type: LV                     "LoginA": null,
       Name: 15801570690            "TInfo": {
       Pwd: 123456                      "U2": "ttt"
                                    }
                                }
                            ]

    postbody:                "postbody": [
    - TInfo:                     {
       U2: ttt                       "Login": [
      LoginA:                            {
      Login:                                  "Pwd": 123456,
      - Type:                                 "Type": {
         Name: 15801570690                        "Name": 15801570690
        Pwd: 123456                            }
      PwdA: print ('aa')                 }
                                       ],
                                       "LoginA": null,
                                        "PwdA": "print ('aa')
                                        "TInfo": {
                                            "U2": "ttt"
                                        }
                                  }
                                ]
  • 相关阅读:
    处理器及其调度
    java面向对象
    操作系统概述
    mysql 基础操作
    java集合类详解
    java数组
    java方法
    Python—进程间通信
    Python—TCP的黏包问题以及UDP的分片问题
    Python—网络通信编程之tcp非阻塞通信(socketserver)
  • 原文地址:https://www.cnblogs.com/kuzaman/p/7456932.html
Copyright © 2020-2023  润新知