當前位置: 首頁>>代碼示例>>Python>>正文


Python STEP_REGISTRY.load_func方法代碼示例

本文整理匯總了Python中lettuce.registry.STEP_REGISTRY.load_func方法的典型用法代碼示例。如果您正苦於以下問題:Python STEP_REGISTRY.load_func方法的具體用法?Python STEP_REGISTRY.load_func怎麽用?Python STEP_REGISTRY.load_func使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在lettuce.registry.STEP_REGISTRY的用法示例。


在下文中一共展示了STEP_REGISTRY.load_func方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: step

# 需要導入模塊: from lettuce.registry import STEP_REGISTRY [as 別名]
# 或者: from lettuce.registry.STEP_REGISTRY import load_func [as 別名]
def step(step_func_or_sentence):
    """Decorates a function, so that it will become a new step
    definition.
    You give step sentence either (by priority):
    * with step function argument (first example)
    * with function doc (second example)
    * with the function name exploded by underscores (third example)

    Example::

        >>> from lettuce import step
        >>> from models import contact
        >>>
        >>> # First Example
        >>> step(r'Given I delete the contact "(?P<name>.*)" from my address book')
        ... def given_i_do_something(step, name):
        ...     contact.delete_by_name(name)
        ...     assert step.sentence == 'Given I delete the contact "John Doe" from my address book'
        ...
        >>> # Second Example
        >>> @step
        ... def given_i_delete_a_contact_from_my_address_book(step, name):
        ...     '''Given I delete the contact "(?P<name>.*)" from my address book'''
        ...     contact.delete_by_name(name)
        ...     assert step.sentence == 'Given I delete the contact "(?P<name>.*)" from my address book'
        ...
        >>> # Third Example
        >>> @step
        ... def given_I_delete_the_contact_John_Doe_from_my_address_book(step):
        ...     contact.delete_by_name("John Doe")
        ...     assert step.sentence == 'Given I delete the contact John Doe from my address book'


    Notice that all step definitions take a step object as argument.
    """
    if _is_step_sentence(step_func_or_sentence):
        return lambda func: STEP_REGISTRY.load(step_func_or_sentence, func)
    else:
        return STEP_REGISTRY.load_func(step_func_or_sentence)
開發者ID:raitisdembovskis,項目名稱:lettuce,代碼行數:41,代碼來源:decorators.py


注:本文中的lettuce.registry.STEP_REGISTRY.load_func方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。