本文整理汇总了Python中types.ModuleType.task方法的典型用法代码示例。如果您正苦于以下问题:Python ModuleType.task方法的具体用法?Python ModuleType.task怎么用?Python ModuleType.task使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类types.ModuleType
的用法示例。
在下文中一共展示了ModuleType.task方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_should_collect_single_after_action_with_teardown_flag
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import task [as 别名]
def test_should_collect_single_after_action_with_teardown_flag(self):
@after("spam", teardown=True)
def action():
pass
module = ModuleType("mock_module")
module.task = action
self.reactor.collect_tasks_and_actions_and_initializers(module)
示例2: test_should_collect_single_after_action
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import task [as 别名]
def test_should_collect_single_after_action(self):
@after("spam")
def action():
pass
module = ModuleType("mock_module")
module.task = action
self.reactor.collect_tasks_and_actions_and_initializers(module)
self.assertEquals(self.execution_manager.register_action.call_count, 1)
self.assertTrue(isinstance(self.execution_manager.register_action.call_args[0][0], Action) and
len(self.execution_manager.register_action.call_args[0]) == 1)
示例3: test_should_collect_single_initializer
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import task [as 别名]
def test_should_collect_single_initializer(self):
def init():
pass
setattr(init, INITIALIZER_ATTRIBUTE, True)
module = ModuleType("mock_module")
module.task = init
self.reactor.collect_tasks_and_actions_and_initializers(module)
self.assertEquals(self.execution_manager.register_initializer.call_count, 1)
self.assertTrue(isinstance(self.execution_manager.register_initializer.call_args[0][0], Initializer) and
len(self.execution_manager.register_initializer.call_args[0]) == 1)
示例4: test_should_collect_single_task
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import task [as 别名]
def test_should_collect_single_task(self):
def task():
pass
setattr(task, TASK_ATTRIBUTE, True)
module = ModuleType("mock_module")
module.task = task
self.reactor.collect_tasks_and_actions_and_initializers(module)
self.assertEquals(len(self.execution_manager.register_task.call_args_list), 1)
self.assertTrue(isinstance(self.execution_manager.register_task.call_args[0][0], Task) and len(
self.execution_manager.register_task.call_args[0]) == 1)
self.assertEquals(self.execution_manager.register_task.call_args[0][0].name, "task")
示例5: test_should_collect_single_after_action_with_only_once_flag
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import task [as 别名]
def test_should_collect_single_after_action_with_only_once_flag(self):
@after("spam", only_once=True)
def action():
pass
module = ModuleType("mock_module")
module.task = action
def register_action(action):
if not action.only_once:
raise AssertionError("Action is not marked as only_once")
self.execution_manager.register_action = register_action
self.reactor.collect_tasks_and_actions_and_initializers(module)
示例6: test_should_collect_single_initializer_with_environments
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import task [as 别名]
def test_should_collect_single_initializer_with_environments(self):
def init():
pass
setattr(init, INITIALIZER_ATTRIBUTE, True)
setattr(init, ENVIRONMENTS_ATTRIBUTE, ["any_environment"])
module = ModuleType("mock_module")
module.task = init
class ExecutionManagerMock(object):
def register_initializer(self, initializer):
self.initializer = initializer
def register_late_task_dependencies(self, dependencies):
pass
execution_manager_mock = ExecutionManagerMock()
self.reactor.execution_manager = execution_manager_mock
self.reactor.collect_tasks_and_actions_and_initializers(module)
self.assertEquals(execution_manager_mock.initializer.environments, ["any_environment"])