-1

Attempting to call a multiline step definition from another multiline step definition. The lettuce.py website has little to say on the matter.

@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 ) )
Ben Crowhurst
  • 8,204
  • 6
  • 48
  • 78

2 Answers2

0

While not really answering the question. We've proceeded for the moment with the following step definition:

@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" ]

And raised an issue with the developers.

Ben Crowhurst
  • 8,204
  • 6
  • 48
  • 78
0

This issue is product related.

This should be fixed in the infoxchange/new-parser branch. -- Danielle Madeley

Ben Crowhurst
  • 8,204
  • 6
  • 48
  • 78