如何使用多行步骤定义调用其他多行步骤定义

时间:2014-09-01 08:55:59

标签: python cucumber bdd lettuce

尝试从另一个多线步骤定义调用多线步骤定义。在这个问题上,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 ) )

2 个答案:

答案 0 :(得分:0)

虽然没有真正回答这个问题。我们暂时采用​​以下步骤定义:

@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

答案 1 :(得分:0)

此问题与product相关。

  

这应该在infoxchange / new-parser分支中修复。 - Danielle Madeley

相关问题