首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >指定行为表行数据类型

指定行为表行数据类型
EN

Stack Overflow用户
提问于 2018-05-31 23:13:38
回答 1查看 2.6K关注 0票数 0

在这里,我编写了一个测试来确定API是否正在使用预期的内容响应错误的请求……

代码语言:javascript
复制
Scenario: Unkown user response body properties contain expected content
    Given I have a valid client auth token
    And I request a user with an unknown "valid" uuid
    And I get the response json
    Then the expected fields should contain expected content
    | field      | content               |
    | statusCode | 404                   |
    | error      | Not Found             |
    | message    | User record not found |

下面是相应的步骤:

代码语言:javascript
复制
@then(u'the expected fields should contain expected content')
def step_impl(context):
    for row in context.table:
        received_content = str(context.request_json.get(row['field']))
        expected_content = row['content']
        assert_equal(received_content, expected_content)

Behave似乎将表行内容转换为字符串。

我的问题是:是否可以在Behave表中指定单元格的数据类型?

在实际的响应中,statusCode是一个整数,但正如您在我的步骤函数中看到的那样,为了验证它,我被迫将请求内容转换为字符串。如果我可以指定我在content列中传递的404是一个整数,我就不需要这么做了。

EN

回答 1

Stack Overflow用户

发布于 2018-06-02 06:57:16

可以为behave表中的列指定数据类型,但不必为列中的特定行指定数据类型。请参阅此tutorial。它解释了如何使用behave的register_type实现用户定义的类型。

另一种选择是使用behave的parser。这是我找到的最接近你要找的东西了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50627578

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档