本文整理汇总了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, (), {}))
示例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: "")
示例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, (), {}))
示例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)
示例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)