本文整理汇总了Python中lettuce.registry.CALLBACK_REGISTRY.clear方法的典型用法代码示例。如果您正苦于以下问题:Python CALLBACK_REGISTRY.clear方法的具体用法?Python CALLBACK_REGISTRY.clear怎么用?Python CALLBACK_REGISTRY.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lettuce.registry.CALLBACK_REGISTRY
的用法示例。
在下文中一共展示了CALLBACK_REGISTRY.clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_after_each_all_is_executed_before_each_all
# 需要导入模块: from lettuce.registry import CALLBACK_REGISTRY [as 别名]
# 或者: from lettuce.registry.CALLBACK_REGISTRY import clear [as 别名]
def test_after_each_all_is_executed_before_each_all():
"terrain.before.each_all and terrain.after.each_all decorators"
import lettuce
from lettuce.fs import FeatureLoader
world.all_steps = []
loader_mock = mock.Mock(spec=FeatureLoader)
old_sys_path = lettuce.sys.path
old_fs = lettuce.fs
old_FileSystem = lettuce.fs.FileSystem
old_Feature = lettuce.Feature
lettuce.sys.path = mock.Mock(spec=old_sys_path)
lettuce.sys.path.insert = mock.Mock()
lettuce.sys.path.remove = mock.Mock()
lettuce.fs = mock.Mock(spec=old_fs)
lettuce.fs.FileSystem = mock.Mock(spec=old_FileSystem)
lettuce.Feature = mock.Mock(spec=old_Feature)
loader_mock.find_feature_files = mock.Mock(return_value=['some_basepath/foo.feature'])
lettuce.fs.FeatureLoader = mock.Mock(return_value=loader_mock)
lettuce.Feature.from_file = mock.Mock(return_value=Feature.from_string(FEATURE2))
runner = lettuce.Runner('some_basepath')
CALLBACK_REGISTRY.clear()
@before.all
def set_state_to_before():
world.all_steps.append('before')
@step('append "during" to states')
def append_during_to_all_steps(step):
world.all_steps.append("during")
@after.all
def set_state_to_after(total):
world.all_steps.append('after')
isinstance(total, TotalResult)
runner.run()
lettuce.sys.path.insert.assert_called_with(0, 'some_basepath')
lettuce.sys.path.remove.assert_called_with('some_basepath')
loader_mock.find_and_load_step_definitions.assert_called_once
lettuce.Feature.from_file.assert_called_once_with('some_basepath/foo.feature')
assert_equals(
world.all_steps,
['before', 'during', 'during', 'after'],
)
lettuce.sys.path = old_sys_path
lettuce.fs = old_fs
lettuce.fs.FileSystem = old_FileSystem
lettuce.Feature = old_Feature
示例2: run
# 需要导入模块: from lettuce.registry import CALLBACK_REGISTRY [as 别名]
# 或者: from lettuce.registry.CALLBACK_REGISTRY import clear [as 别名]
def run(self):
""" Find and load step definitions, and them find and load
features under `base_path` specified on constructor
"""
CALLBACK_REGISTRY.clear(name='output')
CALLBACK_REGISTRY.clear(name='common_output')
if self.verbosity is 0:
from lettuce.plugins import non_verbose as output
elif self.verbosity is 1:
from lettuce.plugins import dots as output
elif self.verbosity is 2:
from lettuce.plugins import scenario_names as output
elif self.verbosity is 3:
from lettuce.plugins import shell_output as output
else:
from lettuce.plugins import colored_shell_output as output
reload(output)
self.output = output
results = []
if self.single_feature:
features_files = [self.single_feature]
else:
features_files = self.loader.find_feature_files()
if self.random:
random.shuffle(features_files)
if not features_files:
self.output.print_no_features_found(self.loader.base_dir)
return
# only load steps if we've located some features.
# this prevents stupid bugs when loading django modules
# that we don't even want to test.
try:
self.loader.find_and_load_step_definitions()
except StepLoadingError as e:
print "Error loading step definitions:\n", e
raise SystemExit(3)
failed = False
try:
call_hook('before', 'all')
for filename in features_files:
feature = Feature.from_file(filename)
results.append(
feature.run(self.scenarios,
tags=self.tags,
random=self.random,
failfast=self.failfast))
except exceptions.LettuceSyntaxError as e:
sys.stderr.write(e.msg)
failed = True
except exceptions.FailFast:
print
print ("Lettuce aborted running any more tests "
"because was called with the `--failfast` option")
failed = True
except Exception:
# ensure our output is undiverted
sys.stdout = real_stdout
print "Exception in Lettuce itself!"
failed = True
raise
except BaseException:
failed = True
raise
finally:
total = TotalResult(results)
total.output_format()
call_hook('after', 'all', total)
if not total.passed:
failed = True
if failed:
raise SystemExit(2)
return total