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)的更多相关文章

  1. IOS开发中数据持久化的几种方法--NSUserDefaults

    IOS开发中数据持久化的几种方法--NSUserDefaults IOS 开发中,经常会遇到需要把一些数据保存在本地的情况,那么这个时候我们有以下几种可以选择的方案: 一.使用NSUserDefaul ...

  2. jquery ajax中支持哪些返回类型以及js中判断一个类型常用的方法?

    1 jquery ajax中支持哪些返回类型在JQuery中,AJAX有三种实现方式:$.ajax() , $.post , $.get(). 预期服务器返回的数据类型.如果不指定,jQuery 将自 ...

  3. 哈希算法和字典类的定义,DataSet中数据遍历的几种方法

    哈希算法的基本操作: 1.  哈希表(HashTable)简述   在.NET Framework中,Hashtable是System.Collections命名空间提供的一个容器,用于处理和表现类似 ...

  4. JavaScript中判断对象类型的种种方法

    我们知道,JavaScript中检测对象类型的运算符有:typeof.instanceof,还有对象的constructor属性: 1) typeof 运算符 typeof 是一元运算符,返回结果是一 ...

  5. 转 JavaScript中判断对象类型的种种方法

    我们知道,JavaScript中检测对象类型的运算符有:typeof.instanceof,还有对象的constructor属性: 1) typeof 运算符 typeof 是一元运算符,返回结果是一 ...

  6. MySQL数据库修改数据表类型(引擎)的方法

    MySQL数据库使用事务,相关数据表必须为InnoDB引擎 查看数据表状态: SHOW TABLE STATUS FROM wawa WHERE NAME='ww_invite_code_temp'; ...

  7. 为什么Javascript中的基本类型能调用方法?

    我们从一道笔试题说起: var str = 'string'; str.pro = 'hello'; console.log(str.pro + 'world'); 输出啥?要理解这个问题,我们得从头 ...

  8. 三种查看SqlServer中数据物理pge页的方法

    1.根据数据记录查看当前记录所在的文件编号.page页.以及在页中的插槽. 示例如下: SELECT top %%physloc%%, sys.fn_physlocFormatter (%%physl ...

  9. JS中的原始类型和判断方法

    ECMAScript 中定义了 7 种原始类型: Boolean String Number Null Undefined Symbol(新定义) BigInt(新定义) 注意: 原始类型不包含 Ob ...

随机推荐

  1. pta总结2

    7-1 币值转换 (20 分) 输入一个整数(位数不超过9位)代表一个人民币值(单位为元),请转换成财务要求的大写中文格式.如23108元,转换后变成"贰万叁仟壹百零捌"元.为了简 ...

  2. neo4j 学习笔记

    1.参考 https://blog.csdn.net/appleyk/article/category/7408344 系列文章 (不支持 spring boo 2.0 以下的,入门可做参考) 2.底 ...

  3. 一起学HBase——总结HBase中的PUT、GET、DELETE操作

    传统的关系型数据库有CRUD增删改查操作,同样对于NoSQL列式数据库也有CRUD操作.本文对HBase中常用的Scan.GET.PUT.DELETE操作的用法做个总结. Put操作 Put相当于传统 ...

  4. 多台CentOS服务器下实现SSH免密码登录

    ROOT用户下实现SSH免密码登录 第一步:进入目录/root/.ssh $ cd  /root/.ssh/ 执行以下命令,会在当前目录下生成公钥(id_rsa.pub)/私钥(id_rsa)对 第二 ...

  5. (三)ajax请求不同源之websocket跨域

    WebSocket是一种通信协议,使用ws://(非加密)和wss://(加密)作为协议前缀.该协议不实行同源政策,只要服务器支持,就可以通过它进行跨源通信. 一.WebSocket目标 在一个单独的 ...

  6. 2019-2-13TextBox技巧

    清空所有的TextBox文本框 思路:这些TextBox都是在一个窗体上的,这时候我们可以利用一个循环去遍历窗体上所有的TextBox控件.(代码如下) foreach (Control i in C ...

  7. DWM1000 测距原理简单分析 之 SS-TWR代码分析1 -- [蓝点无限]

    蓝点DWM1000 模块已经打样测试完毕,有兴趣的可以申请购买了,更多信息参见 蓝点论坛 正文: 这一篇内容主要是通过官方源码理解SS-TWR 细节 代码下载链接:https://download.c ...

  8. NEERC-2017

    A. Archery Tournament 用线段树套set维护横坐标区间内的所有圆,查询时在$O(\log n)$个set中二分查找即可. 时间复杂度$O(n\log^2n)$. #include& ...

  9. Hadoop Java API 操作 hdfs--1

    Hadoop文件系统是一个抽象的概念,hdfs仅仅是Hadoop文件系统的其中之一. 就hdfs而言,访问该文件系统有两种方式:(1)利用hdfs自带的命令行方式,此方法类似linux下面的shell ...

  10. [BZOJ2457][BeiJing2011]双端队列 (单调性)

    正如lyd所说,和数据结构本身没什么太大关联 题意 中文题面   Sherry现在碰到了一个棘手的问题,有N个整数需要排序.        Sherry手头能用的工具就是若干个双端队列.        ...