【问题标题】:How to have multiline step definitions calling other multiline step definitions如何让多行步骤定义调用其他多行步骤定义
【发布时间】:2014-09-01 08:55:59
【问题描述】:

试图从另一个多行步骤定义调用多行步骤定义。 lettuce.py 网站在这件事上几乎没有say

@step( u'I create a "([^"]*)" with the definition:$' )
    def i_create_a_resource_with_the_definition( step, resource ):
        body = ""

        if step.multiline != "":
            definition = json.loads( step.multiline )
            body = json.dumps( definition )

        url = world.url + "/" + resource + "s"

        world.response = world.perform_http_request( url = url, method = "POST", body = body )

@step( u'I create a duplicate "([^"]*)" with the definition:$' )
    def i_create_a_duplicate_resource_with_the_definition( step, resource ):
        step.behave_as( """
            I create a "{resource}" with the definition:
        """.format( resource = resource ) )

【问题讨论】:

    标签: python cucumber bdd lettuce


    【解决方案1】:

    虽然没有真正回答问题。我们暂时按照以下步骤定义进行:

    @step( u'I "([^"]*)" (a|a duplicate) "([^"]*)" with the definition:$' )
    def i_method_a_resource_with_the_definition( step, method, word, resource ):
        body = ""
    
        if step.multiline != "":
            definition = json.loads( step.multiline )
            body = json.dumps( definition )
    
        url = world.url + "/" + resource + "s"
    
        world.response = world.perform_http_request( url = url, method = method, body = body )
    
        if "location" in world.response.headers:
            world.last_resource_identifier = world.response.headers[ "location" ]
    

    并向开发人员提出了issue

    【讨论】:

      【解决方案2】:

      此问题与product 相关。

      这应该在 infoxchange/new-parser 分支中修复。 ——丹妮尔·马德利

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-07-23
        • 1970-01-01
        • 2019-07-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多