Giter VIP home page Giter VIP logo

parseyamlvariable's Introduction

parseYamlVariable

在yml用例描述中实现函数/变量的定义和调用

在Python语言中,函数的调用形式包含如下四种形式:

  • 无参数:func()
  • 顺序参数:func(a, b)
  • 字典参数:func(a=1, b=2)
  • 混合类型参数:func(1, 2, a=3, b=4)

于是,以上四种类型的函数定义在YAML/JSON中就会写成如下样子。

  • 无参数:${func()}
  • 顺序参数:${func(a, b)}
  • 字典参数:${func(a=1, b=2)}
  • 混合类型参数:${func(1, 2, a=3, b=4)}

yml文件是文本文件,无法直接写python代码,因此在加载yml文件时,需要识别出函数并完成调用。

注意:yml文件内不支持注释(注释掉的变量或函数仍会进行查找)

目录结构:

annoymousLogin.yaml ---用例文件

extract.yaml ---存放变量的yml文件

parse.py ---解析yaml文件内的函数与变量,输出结果

debugtalk.py ---存放自定义函数的文件,其余py文件内的自定义函数可导入debugtalk.py内

yaml_util.py ---读取用例并实现变量解析过程

参数化

在yml文件中增加parameters字段:

parameters: username-pwd: ${P(logindata.csv)}

通过$+["parameterize", "P"]识别参数化读取csv文件内容。

csv格式要求:

①第一名必须为字段名,多个字段以","隔开;

②第二行开始为各个字段的值,同样以","隔开;

③引用的参数$var名称必须与csv中设置的一致;

parseyamlvariable's People

Contributors

wozengkeai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.