BDD中数据的类型及处理方法(python)
BDD中提供了两种数据类型,table和text,以下是数据的文档介绍,最后有我的两个小例子。
1、class behave.model.Table(headings, line=None, rows=None)
A table extracted from a feature file.
Table instance data is accessible using a number of methods:
iteration
Iterating over the Table will yield the Row instances from the .rows attribute.
indexed access
Individual rows may be accessed directly by index on the Table instance; table[0] gives the first non-heading row and table[-1] gives the last row.
The attributes are:
headings
The headings of the table as a list of strings.
rows
An list of instances of Row that make up the body of the table in the feature file.
Tables are also comparable, for what that’s worth. Headings and row data are compared.
2、class behave.model.Row(headings, cells, line=None, comments=None)
One row of a table parsed from a feature file.
Row data is accessible using a number of methods:
iteration
Iterating over the Row will yield the individual cells as strings.
named access
Individual cells may be accessed by heading name; row[‘name’] would give the cell value for the column with heading “name”.
indexed access
Individual cells may be accessed directly by index on the Row instance; row[0] gives the first cell and row[-1] gives the last cell.
The attributes are:
cells
The list of strings that form the cells of this row.
headings
The headings of the table as a list of strings.
Rows are also comparable, for what that’s worth. Only the cells are compared.
And Text may be associated with Steps:
3、class behave.model.Text
Store multiline text from a Step definition.
The attributes are:
value
The actual text parsed from the feature file.
content_type
Currently only ‘text/plain’.
例子:
1、table
json_data = []
for row in context.table:
adict = {}
if hasattr(row, 'name'):
adict['name'] = row['name']
json_data.append(adict)
2、text
expected_datas = json.loads(context.text)
BDD中数据的类型及处理方法(python)的更多相关文章
- IOS开发中数据持久化的几种方法--NSUserDefaults
IOS开发中数据持久化的几种方法--NSUserDefaults IOS 开发中,经常会遇到需要把一些数据保存在本地的情况,那么这个时候我们有以下几种可以选择的方案: 一.使用NSUserDefaul ...
- jquery ajax中支持哪些返回类型以及js中判断一个类型常用的方法?
1 jquery ajax中支持哪些返回类型在JQuery中,AJAX有三种实现方式:$.ajax() , $.post , $.get(). 预期服务器返回的数据类型.如果不指定,jQuery 将自 ...
- 哈希算法和字典类的定义,DataSet中数据遍历的几种方法
哈希算法的基本操作: 1. 哈希表(HashTable)简述 在.NET Framework中,Hashtable是System.Collections命名空间提供的一个容器,用于处理和表现类似 ...
- JavaScript中判断对象类型的种种方法
我们知道,JavaScript中检测对象类型的运算符有:typeof.instanceof,还有对象的constructor属性: 1) typeof 运算符 typeof 是一元运算符,返回结果是一 ...
- 转 JavaScript中判断对象类型的种种方法
我们知道,JavaScript中检测对象类型的运算符有:typeof.instanceof,还有对象的constructor属性: 1) typeof 运算符 typeof 是一元运算符,返回结果是一 ...
- MySQL数据库修改数据表类型(引擎)的方法
MySQL数据库使用事务,相关数据表必须为InnoDB引擎 查看数据表状态: SHOW TABLE STATUS FROM wawa WHERE NAME='ww_invite_code_temp'; ...
- 为什么Javascript中的基本类型能调用方法?
我们从一道笔试题说起: var str = 'string'; str.pro = 'hello'; console.log(str.pro + 'world'); 输出啥?要理解这个问题,我们得从头 ...
- 三种查看SqlServer中数据物理pge页的方法
1.根据数据记录查看当前记录所在的文件编号.page页.以及在页中的插槽. 示例如下: SELECT top %%physloc%%, sys.fn_physlocFormatter (%%physl ...
- JS中的原始类型和判断方法
ECMAScript 中定义了 7 种原始类型: Boolean String Number Null Undefined Symbol(新定义) BigInt(新定义) 注意: 原始类型不包含 Ob ...
随机推荐
- (五)Knockout template模版渲染
基础 template绑定通过模板将数据render到页面.模板绑定对于构建嵌套结构的页面非常方便.默认情况, Knockout用的是流行的jquery.tmpl模板引擎.使用它的话,需要在安装页面下 ...
- java 小程序开发PKCS7Padding 解密方法实现,以及错误Cannot find any provider supporting AES/CBC/PKCS7Padding 解决办法
近日在对接小程序API,其中wx.getUserInfo api返回的数据encryptedData 的解密算法要求为: AES-128-CBC,数据采用PKCS#7填充. 经过一番查询,得到java ...
- sklearn数据库-【老鱼学sklearn】
在做机器学习时需要有数据进行训练,幸好sklearn提供了很多已经标注好的数据集供我们进行训练. 本节就来看看sklearn提供了哪些可供训练的数据集. 这些数据位于datasets中,网址为:htt ...
- day10_friest_自动化
一.知识回顾, 1.构造函数:def __del__(self)是类执行完后,需要将某些如连接等关闭,可将关闭代码写在该函数中,既是实例被销毁的时候执行 2.私有寒素:def __say(self)表 ...
- json 函数
一, json序列化和反序列化 JSON.stringify( ) —— 将对象序列化为JSON字符串 JSON.parse( ) —— 将JSON数据解析为Javascript对象 二,判断json ...
- Java_String
整理一下java中关于String的内容.Spring应该是java中使用最频繁的类了,那么今天我们仔细研究下关于Spring的内容. 定义: String类是一个字符串类型的类,使用" ...
- __x__(3)0905第二天__W3C标准集合
World Wide Web Consortium 万维网联盟(外语缩写:W3C)标准不是某一个标准,而是一系列标准的集合. 创建于 1994 年,是 Web 技术领域最具权威和影响力的国际中立性技术 ...
- 10_ for 练习 _ is Prime Number ?
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- Winform 关闭按钮
问题:我希望树形导航目录窗体在打开一条记录后自动隐藏,然后再次点击主页面打开按钮的时候在自动显示,这样就能保证树形目录仍旧显示隐藏前的展开状态.这里遇到一个问题,就是点击窗体右上角的关闭按钮时,默认情 ...
- jenkins-参数化构建(三)插件:Git Parameter
一.下载插件Git Parameter (更加省事) 在配置中branch和tag用的比较多 注意:Credential 可以添加密码,jenkins如果在root用户下载的请改 /etc/sys ...