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 ...
随机推荐
- IDEA手动创建JFinal项目
http://www.jfinal.com/share/674 https://www.oschina.net/question/265150_110300
- SpringBoot之hello world!
哈哈哈,还是在元旦这一天对你下手了.麻溜的给自己充电,在这个寒冬,不断听到裁员的消息或者新闻,可对于我这个外包和外派的人来说,好像并没有受到什么影响.可能是人手不够可能是项目很忙.对于明年的三月金四月 ...
- scrapy_redis 相关: 将 jobdir 保存的爬虫进度转移到 Redis
0.参考 Scrapy 隐含 bug: 强制关闭爬虫后从 requests.queue 读取的已保存 request 数量可能有误 1.说明 Scrapy 设置 jobdir,停止爬虫后,保存文件目录 ...
- Python_queue单项队列
队列(queue),实现程序间的松耦合 队列的三种类: class queue.Queue(maxsize)# 先进先出, maxsize 指定队列长度,线程安全的清况下,可以放入实例,对实例进行传输 ...
- ssh报错 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
今天登陆远程主机的时候,出现如下的报错信息 ssh 10.0.0.1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WAR ...
- day16匿名函数
匿名函数,好像也就是 lambda 表达式 先来看一段函数,返回 def func(n): return n * 3 print(func(5))15 用lambda表达式写: func = lamb ...
- SparkCore | Rdd| 广播变量和累加器
Spark中三大数据结构:RDD: 广播变量: 分布式只读共享变量: 累加器:分布式只写共享变量: 线程和进程之间 1.RDD中的函数传递 自己定义一些RDD的操作,那么此时需要主要的是,初始化工作 ...
- js 30Dom应用
1.open() 方法用于打开一个新的浏览器窗口或查找一个已命名的窗口. 给open传网址 如果是外站就加个http <input type="button" value= ...
- 数组方括号有趣的split方法
今天看到了split的方法感觉好神奇的样子 split是javascript内置方法 就像join方法是连接数组并转换为字符串一样split方法是把数组拆分成多个部分,而且每一个部分都是数组的元素. ...
- python使用urllib2 http 下载参数的try catch
import urllib2 req = urllib2.Request('http://blog.csdn.net/cqcre')try: urllib2.urlopen(req)except ur ...