当前位置: 首页>>代码示例>>Python>>正文


Python registry.STEP_REGISTRY类代码示例

本文整理汇总了Python中lettuce.registry.STEP_REGISTRY的典型用法代码示例。如果您正苦于以下问题:Python STEP_REGISTRY类的具体用法?Python STEP_REGISTRY怎么用?Python STEP_REGISTRY使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了STEP_REGISTRY类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_match

    def _get_match(self, ignore_case):
        matched, func = None, lambda: None
        for step, func in STEP_REGISTRY.items():
            regex = STEP_REGISTRY.get_regex(step, ignore_case)
            matched = regex.search(self.sentence)
            if matched:
                break

        return matched, StepDefinition(self, func)
开发者ID:MikeHibbert,项目名称:lettuce,代码行数:9,代码来源:core.py

示例2: _get_match

    def _get_match(self, ignore_case):
        matched, func = None, lambda: None
        for regex, func in STEP_REGISTRY.items():
            matched = re.search(regex, self.sentence, ignore_case and re.I or 0)
            if matched:
                break

        return matched, StepDefinition(self, func)
开发者ID:fkoner,项目名称:lettuce-farmer,代码行数:8,代码来源:core.py

示例3: _get_match

    def _get_match(self):
        matched, func = None, lambda: None

        for regex, func in STEP_REGISTRY.iteritems():
            matched = regex.search(self.sentence)
            if matched:
                break

        return matched, StepDefinition(self, func)
开发者ID:raitisdembovskis,项目名称:lettuce,代码行数:9,代码来源:core.py

示例4: test_after_each_all_is_executed_before_each_all

def test_after_each_all_is_executed_before_each_all():
    """terrain.before.each_all and terrain.after.each_all decorators"""

    from lettuce import step
    from lettuce import Runner
    from lettuce.registry import STEP_REGISTRY
    from lettuce.terrain import before, after, world

    world.all_steps = []
    STEP_REGISTRY.clear()

    @before.all
    def set_state_to_before():
        world.all_steps.append('before')

    @step('append 1 in world all steps')
    def append_1_in_world_all_steps(step):
        world.all_steps.append("1")

    @step('append 2 more')
    def append_2_more(step):
        world.all_steps.append("2")

    @step('append 3 in world all steps')
    def append_during_to_all_steps(step):
        world.all_steps.append("3")

    @after.all
    def set_state_to_after(total):
        world.all_steps.append('after')

    runner = Runner(join(abspath(dirname(__file__)),
                         'simple_features', '2nd_feature_dir'))
    runner.run()

    assert_equals(
        world.all_steps,
        ['before', '1', '2', '3', 'after']
    )
开发者ID:raitisdembovskis,项目名称:lettuce,代码行数:39,代码来源:test_terrain.py

示例5: step

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,代码行数:39,代码来源:decorators.py

示例6: init

 def init(self, *args, **kwargs):
     _init_(self, *args, **kwargs)
     STEP_REGISTRY.load_steps(self)
开发者ID:raitisdembovskis,项目名称:lettuce,代码行数:3,代码来源:decorators.py


注:本文中的lettuce.registry.STEP_REGISTRY类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。