코드가 완벽하게 유효합니다. 당신의 위치 인자 (예 : *args
)와 이름이 같은 것 (예 : **kwargs
)을 모두 사용할 수 있습니다.
Feature: Basic computations
In order to play with Lettuce
As beginners
We will implement addition and subtraction
Scenario: Sum of 0 and 1
Given I have to add the numbers 0 and 1
When I compute its factorial
Then I see the number 1
Scenario: Difference of 3 and 5
Given I have to substract 5 from 3
When I compute their difference
Then I see the number -2
및 steps.py
:
당신이
math.feature
다음이 고려
from lettuce import *
@step('I have to add the numbers (\d+) and (\d+)')
def have_to_add(step, number1, number2):
world.number1 = int(number1)
world.number2 = int(number2)
@step('I have to substract (?P<subtrahend>) from (?P<minuend>)')
def have_to_substract(step, minuend, subtrahend):
world.minuend = int(minuend)
world.subtrahend = int(subtrahend)
@step('I compute their difference')
def compute_difference(step):
world.number = world.minuend - world.subtrahend
@step('I compute their sum')
def compute_sum(step):
world.number = world.number1 + world.number2
@step('I see the number (\d+)')
def check_number(step, expected):
expected = int(expected)
assert world.number == expected, "Got %d" % world.number
은 뺄셈의 예를 자세히보세요, 당신이 오히려 이름으로 캡처 된 변수를 참조하는 방법을 보여줍니다 다음 위치로.
예를 들어 이런 식으로 사용하지는 않으므로이 사용법과 관련된 설명서 항목이 있습니까? 어쨌든 나는 검증 할 것이다. – zinking
나는이 모든 것을 내 프로젝트에서 사용한다. 당신이 직면 한 문제는 그것이 효과가 없을 것이라고 믿게합니까? –
아무 문제 없어, 내 프로젝트에서 아무도 이런 식으로 사용하지 않습니다. 확인해주세요. – zinking