Skip to content

Instantly share code, notes, and snippets.

@dunossauro
Created November 8, 2017 17:47
Show Gist options
  • Save dunossauro/8f7b001b5ba3612d5ace891a1e25f8ee to your computer and use it in GitHub Desktop.
Save dunossauro/8f7b001b5ba3612d5ace891a1e25f8ee to your computer and use it in GitHub Desktop.
import problemas with radish-bdd
from operator import add
from radish import given, when, then
@given("I have the numbers {number1:g} and {number2:g}")
def have_numbers(step, number1, number2):
step.context.number1 = number1
step.context.number2 = number2
@when("I sum them")
def sum_numbers(step):
step.context.result = step.context.calculator.add(step.context.number1,
step.context.number2)
@then("I expect the result to be {result:g}")
def expect_result(step, result):
assert step.context.result == result
from radish import before, after
import calc
# from calc import calculator
@before.each_scenario
def init_calculator(scenario):
scenario.context.calculator = calc.calculator
# scenario.context.calculator = calculator
@after.each_scenario
def destory_calculator(scenario):
del scenario.context.calculator
.
├── calc
│ ├── calculator.py
│ └── __init__.py
├── features
│ └── SumNumbers.feature
└── radish
├── __init__.py
├── steps.py
└── terrain.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment