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. python 列表 元组 字符串

    列表添加: list.append() list.extend() list.insert() 列表删除: list.remove()   #删除某一个元素 list.pop()  #删除某一个返回删 ...

  2. Ubuntu下 安装MiniGUI

    1. 需要下载的组件 首先需要这些安装包,这些安装包可以在MiniGUI官网上下载. libminigui-gpl-3_0_12.tar.gzmg-samples-3_0_12.tar.gzfreet ...

  3. main函数中System.exit()的作用

    main()主函数再熟悉不过,了解java的人也都知道System.exit()方法是停止虚拟机运行.那这里为什么还要单独写一篇博客,都是源于朋友发的一张最近刚买的T恤照片,就是上面这张图.这是一个经 ...

  4. CSS3标准盒模型还是IE怪异模型box-sizing属性的应用设置

    在一个文档中,每个元素都被表示为一个矩形的盒子.盒子模型具有4个属性['外边距(margin)','边框(border)','内边距(padding)','内容(content)']. 我们要设置某个 ...

  5. Beta冲刺4/7

    目录 摘要 团队部分 个人部分 摘要 队名:小白吃 组长博客:hjj 作业博客:beta冲刺(4/7) 团队部分 后敬甲(组长) 过去两天完成了哪些任务 整理博客 ppt模板 接下来的计划 做好机动. ...

  6. java代码获取多边形的中心点

    package com.skjd.util; import java.util.ArrayList; import java.util.List; /** * 坐标以及电子围栏相关的工具类 * @au ...

  7. 2018-2019-1 20189201 《LInux内核原理与分析》补漏_1125写

    我的愿望是 好好学习Linux 一.题目与解释 1 test.txt 中的内容是: No Name Mark Percent 01 tom 69 91 02 jack 71 87 03 alex 68 ...

  8. 6101 最优贸易 (双向spfa)

    描述C国有 n 个大城市和 m 条道路,每条道路连接这 n 个城市中的某两个城市.任意两个城市之间最多只有一条道路直接相连.这 m 条道路中有一部分为单向通行的道路,一部分为双向通行的道路,双向通行的 ...

  9. C#からネイティブDLLを呼び出す場合のVSからのデバッグのジレンマを解決する

    「C#を使う最大のメリットって.やっぱり.Visual Studioですよね!」って自信を持って言いたいですね. という心境ではあるんですが.私の仕事はどっちかというとC++よりなので.どうしても.D ...

  10. PBRT笔记(4)——颜色和辐射度

    SPD 光谱功率分布 CoefficientSpectrum 根据给定采样数表示光谱,为RGBSpectrum.SampledSpectrum的父类. 重载大量的基础代码,比较简单不做赘述.其中为了方 ...