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 ...
随机推荐
- 寻找符合条件的最短子字符串——SLIDING WINDOW
简介 用一个可伸缩的窗口遍历字符串,时间复杂度大致为O(n).适用于“寻找符合某条件的最小子字符串”题型. 题目 链接 求某字符串T中含有某字符串S的所有字符的最小子字符串.如果不存在则返回" ...
- 关闭 Window 之后,无法设置 Visibility,也无法调用 Show、ShowDialogor 或 WindowInteropHelper.EnsureHandle。
参考网址: 1.WPF Tips: Window.ShowDialog()方法:Cannot set Visibility or call Show, ShowDialog, or WindowInt ...
- java日志规约及配置示例终极总结
目录 什么是日志 常用日志框架 日志级别详解 日志的记录时机 日志使用规约 logback 配置示例 loh4j2 配置示例 什么是日志? 简单的说,日志就是记录程序的运行轨迹,方便查找关键信息,也方 ...
- Codeforces.1043F.Make It One(DP 容斥)
题目链接 \(Description\) 给定\(n\)个数\(A_i\),求最少选出多少个数,使得它们的\(\gcd\)为\(1\). \(n,A_i\leq3\times10^5\). \(Sol ...
- 17使用systemd方式开机自动启动Home Assistant服务
2018-03-20 15:48:36 转移自网易博客! 首先使用编写文件hass@homeassistant.service,文件内容如下 # 这个文件用于systemd方式自动启动hass服务.# ...
- List GroupBy真实用法,Reflection(反射)用法,Enum用法,正则,搜索下拉布局
1.List GroupBy 用法 var _roomProducts = homesingProducts.GroupBy(t => t.RoomName); RoomedProducts ...
- 一种常见的maven打包后同名文件冲突错误
在使用一些开源框架的时候(比如spark.hadoop.lucene等),偶尔会见到说找不到某个具体实现类或者某个配置(比如spark的akka配置)不见了. 部分例子如下: [Lucene]An S ...
- BOM 浏览器对象模型_window.navigator
window.navigator 对象 包含浏览器和系统信息的 Navigator 对象. 通过这个属性 了解用户的环境信息 window.navigator.userAgent 返回浏览器的 Use ...
- Go九九乘法表
package main import "fmt" func main(){ ; i < ; i ++ { k ++ ; j ++ { { fmt.Printf(" ...
- Android 小票打印USB
第一步USB通信: Usb设备有两种,Host与Accessory 简单来说是主模式与从模式,主模式则android设备给外设供电,反之,外设给android设备充电,对于小票打印,使用的是Host模 ...