Commit 3796e9e9 by Chris Morgan

Docs: fixed some bad example code mixing str % formatting and str.format().

parent 61f54adb
...@@ -43,7 +43,7 @@ Lettuce affords you the ability to write such a "step of steps" with a set of he ...@@ -43,7 +43,7 @@ Lettuce affords you the ability to write such a "step of steps" with a set of he
running blocks of steps running blocks of steps
----------------------- -----------------------
It is sometimes even desirable to run blocks of steps, copy-and-pasted directly from Feature specifications. The ``Step.behave_as`` method lets you do this, and you can use ``string.format`` to fill in parameters dynamically. For example, we can write the above step definition like so: It is sometimes even desirable to run blocks of steps, copy-and-pasted directly from Feature specifications. The ``Step.behave_as`` method lets you do this, and you can use ``str.format`` to fill in parameters dynamically. For example, we can write the above step definition like so:
.. highlight:: python .. highlight:: python
...@@ -54,11 +54,8 @@ It is sometimes even desirable to run blocks of steps, copy-and-pasted directly ...@@ -54,11 +54,8 @@ It is sometimes even desirable to run blocks of steps, copy-and-pasted directly
step.behave_as(""" step.behave_as("""
Given I go to the home page Given I go to the home page
And I click the login button And I click the login button
And I fill in username:%(user)s password:%(pass)s And I fill in username:{user} password:{pass}
And I click "Login" And I click "Login"
""".format({ """.format(user='floppy', pass='banana'))
'user': 'floppy',
'pass': 'banana'
}))
This can be combined with step argument capture for step definitions that are both expressive and DRY. This can be combined with step argument capture for step definitions that are both expressive and DRY.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment