Lettuce用Python的內(nèi)置異常AssertionError標(biāo)記測試失敗。
雖然用自定義字符串描述斷言,需要做一些類似于下面的工作:
from lettuce import step
@step('some step with "(.*)"'):
def some_step(step, from):
assert from == 'expectation', \
"Ooops, '%s' should be equal 'expectation', but isn't" % from
nose是一個Python模塊囤热,提供一組已經(jīng)有很好的描述功能的斷言鹊碍,幸運(yùn)的是它仍然使用AssertionError,使nose完全符合Lettuce胡桃。
下面的例子展示了如何利用nose來寫上面的步驟:
from lettuce import step
from nose.tools import assert_equals
@step('some step with "(.*)"'):
def some_step(step, from):
assert_equals(from, 'expectation')
上一篇:Lettuce: Built-in Django
下一篇:Lettuce:使用Lettuce和Django開發(fā)Web