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


Python StepDict.load方法代码示例

本文整理汇总了Python中aloe.registry.StepDict.load方法的典型用法代码示例。如果您正苦于以下问题:Python StepDict.load方法的具体用法?Python StepDict.load怎么用?Python StepDict.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aloe.registry.StepDict的用法示例。


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

示例1: test_replacing_step

# 需要导入模块: from aloe.registry import StepDict [as 别名]
# 或者: from aloe.registry.StepDict import load [as 别名]
def test_replacing_step():
    """
    Test registering a different step with the same sentence.
    """

    def func1():
        """First function to register as a step."""
        pass

    def func2():
        """Second function to register as a step."""
        pass

    steps = StepDict()

    # This has to be more than re._MAXCACHE; currently 100 on Python 2.7 and
    # 512 on Python 3.5
    step_count = 1024

    sentence = "sentence {0}".format

    # Register some steps
    for num in range(step_count):
        steps.load(sentence(num), func1)

    # Register the same steps again
    for num in range(step_count):
        steps.load(sentence(num), func2)

    # func2 should have replaced func1 everywhere
    for num in range(step_count):
        assert_matches(steps, sentence(num), (func2, (), {}))
开发者ID:electroniceagle,项目名称:aloe,代码行数:34,代码来源:test_registry.py

示例2: test_StepDict_raise_StepLoadingError_if_first_argument_is_not_a_regex

# 需要导入模块: from aloe.registry import StepDict [as 别名]
# 或者: from aloe.registry.StepDict import load [as 别名]
def test_StepDict_raise_StepLoadingError_if_first_argument_is_not_a_regex():
    """
    aloe.STEP_REGISTRY.load(step, func) should raise an error if step is
    not a regex
    """
    steps = StepDict()
    with assert_raises(StepLoadingError):
        steps.load("an invalid regex;)", lambda: "")
开发者ID:electroniceagle,项目名称:aloe,代码行数:10,代码来源:test_registry.py

示例3: test_StepDict_can_load_a_step_composed_of_a_regex_and_a_function

# 需要导入模块: from aloe.registry import StepDict [as 别名]
# 或者: from aloe.registry.StepDict import load [as 别名]
def test_StepDict_can_load_a_step_composed_of_a_regex_and_a_function():
    """
    aloe.STEP_REGISTRY.load(step, func) append item(step, func) to
    STEP_REGISTRY
    """
    steps = StepDict()

    def func():  # pylint:disable=missing-docstring
        return ""

    step = "a step to test"
    steps.load(step, func)

    assert_matches(steps, step, (func, (), {}))
开发者ID:electroniceagle,项目名称:aloe,代码行数:16,代码来源:test_registry.py

示例4: test_StepDict_can_load_a_step_composed_of_a_regex_and_a_function

# 需要导入模块: from aloe.registry import StepDict [as 别名]
# 或者: from aloe.registry.StepDict import load [as 别名]
def test_StepDict_can_load_a_step_composed_of_a_regex_and_a_function():
    """
    aloe.STEP_REGISTRY.load(step, func) append item(step, func) to
    STEP_REGISTRY
    """
    steps = StepDict()

    def func():  # pylint:disable=missing-docstring
        return ""

    step = "a step to test"
    steps.load(step, func)

    step = re.compile(step, re.I | re.U)
    assert_in(step, steps)
    assert_equal(steps[step], func)
开发者ID:kiawin,项目名称:aloe,代码行数:18,代码来源:test_registry.py

示例5: test_StepDict_load_a_step_return_the_given_function

# 需要导入模块: from aloe.registry import StepDict [as 别名]
# 或者: from aloe.registry.StepDict import load [as 别名]
def test_StepDict_load_a_step_return_the_given_function():
    """
    aloe.STEP_REGISTRY.load(step, func) returns func
    """
    steps = StepDict()

    def func():  # pylint:disable=missing-docstring
        return ""

    assert_equal(steps.load("another step", func), func)
开发者ID:electroniceagle,项目名称:aloe,代码行数:12,代码来源:test_registry.py


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