Created
October 11, 2012 05:00
-
-
Save cjgiridhar/3870274 to your computer and use it in GitHub Desktop.
Lettuce Example Python BDD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lettuce import * | |
@step('I have the number (\d+)') | |
def have_the_number(step, number): | |
world.number = int(number) | |
@step('I compute its fibonacci') | |
def compute_its_fibonacci(step): | |
world.number = fibonacci(world.number) | |
@step('I see the number (\d+)') | |
def check_number(step, expected): | |
expected = int(expected) | |
assert world.number == expected | |
def fibonacci(number): | |
number = int(number) | |
if (number == 0) or (number == 1): | |
return 1 | |
else: | |
return fibonacci(number-1) + fibonacci(number-2) | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment