本文整理汇总了Python中types.ModuleType.task1方法的典型用法代码示例。如果您正苦于以下问题:Python ModuleType.task1方法的具体用法?Python ModuleType.task1怎么用?Python ModuleType.task1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类types.ModuleType
的用法示例。
在下文中一共展示了ModuleType.task1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_task_dependencies_with_post_definition_injections_custom_names
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import task1 [as 别名]
def test_task_dependencies_with_post_definition_injections_custom_names(self):
import pybuilder.reactor
with patch("pybuilder.reactor.Task"):
@task
def task1():
pass
@task
@depends(task1)
def task2():
pass
@task("task_3")
@depends(task1)
@dependents(task2)
def task3():
pass
module1 = ModuleType("mock_module_one")
module1.task1 = task1
module1.task2 = task2
module2 = ModuleType("mock_module_two")
module2.task3 = task3
self.reactor.collect_tasks_and_actions_and_initializers(module1)
pybuilder.reactor.Task.assert_has_calls([call("task1", task1, [], ''),
call("task2", task2, [TaskDependency(task1)], '')])
self.reactor.collect_tasks_and_actions_and_initializers(module2)
pybuilder.reactor.Task.assert_has_calls([call("task_3", task3, [TaskDependency(task1)], '')])
self.execution_manager.register_late_task_dependencies.assert_has_calls(
[call({}), call({"task2": [TaskDependency("task_3")]})])
示例2: test_task_dependencies
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import task1 [as 别名]
def test_task_dependencies(self):
import pybuilder.reactor
with patch("pybuilder.reactor.Task"):
@task
def task1():
pass
@task
@depends(task1)
def task2():
pass
@task
def task3():
pass
@task
@depends(optional(task3))
@dependents("task6")
def task4():
pass
@task
@dependents("task6", optional(task3))
def task5():
pass
@task
@depends(task1, optional(task2))
def task6():
pass
module = ModuleType("mock_module")
module.task1 = task1
module.task2 = task2
module.task3 = task3
module.task4 = task4
module.task5 = task5
module.task6 = task6
self.reactor.collect_tasks_and_actions_and_initializers(module)
pybuilder.reactor.Task.assert_has_calls([call("task1", task1, [], ''),
call("task2", task2, [TaskDependency(task1)], ''),
call("task3", task3, [TaskDependency(task5, True)], ''),
call("task4", task4, [TaskDependency(task3, True)], ''),
call("task5", task5, [], ''),
call("task6", task6,
[TaskDependency(task1), TaskDependency(task2, True),
TaskDependency(task4), TaskDependency(task5)], '')])