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 ...
随机推荐
- Winform Focus()函数不起作用 解决办法
private void Form_Load(object sender, EventArgs e) { this.txtName.Focus(); } 光标到不了txtName.可能的原因 TabI ...
- 学习笔记: yield迭代器
yield 与 IEnumerable<T> 结对出现, 可实现按需获取 , 迭代器模式 static void Main(string[] args) { ...
- [转] 扩展微信小程序框架功能
通过第三方 JavaScript 库,扩展微信小程序框架功能. 扩展微信小程序框架功能(1)——Promise ES6 对 Promise 有了原生的支持,但微信开发者工具更新版本(0.11.1122 ...
- eclipse查看一个方法被谁引用(调用)的快捷键四种方式
1.(首推)双击选中该方法,Ctrl+Alt+H 如果你想知道一个类的方法到底被那些其他的类调用,那么请选中这个方法名,然后按“Ctrl+Alt+H”, Eclipse就会显示出这个方法被哪些方法调用 ...
- 微信小程序--家庭记账本开发--07
最终展示以及相关代码 1.最终效果展示 最终效果展示已经根据最初要求使用视频拍摄在抖音上,下面是相关页面展示图片: 2.相关代码 本次开发主要页面则是首页界面以及记账界面以及实现页面跳转,以及记账内容 ...
- 002.RHCS-配置Ceph存储集群
一 前期准备 [kiosk@foundation0 ~]$ ssh ceph@serverc #登录Ceph集群节点 [ceph@serverc ~]$ ceph health #确保集群状态正常 H ...
- BZOJ.2780.[SPOJ8093]Sevenk Love Oimaster(广义后缀自动机)
题目链接 \(Description\) 给定n个模式串,多次询问一个串在多少个模式串中出现过.(字符集为26个小写字母) \(Solution\) 对每个询问串进行匹配最终会达到一个节点,我们需要得 ...
- [POJ1220]NUMBER BASE CONVERSION (高精,进制转换)
题意 任意进制之间的高进的转换 思路 相模倒排,高精处理 代码 我太弱了,下面附一个讨论里发的maigo思路的代码 ],A[]; ],d[]; main(){ for(scanf("%d&q ...
- Java数据库连接与查询
9个步骤: 1.加载数据库驱动: 2.连接数据库: 3.创建语句statement: 5.创建sql语法字符串: 6.执行: 7.如果步骤6是执行新增.修改.删除操作那么返回的是影响的行数,如果是执行 ...
- Unity进阶----AssetBundle_01(2018/10/30)
AssetBundle作用和定义 1).AssetBundle是一个压缩包包含模型.贴图.预制体.声音.甚至整个场景,可以在游戏运行的时候被加载: 2).AssetBundle自身保存着互相的依赖关系 ...