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


Python ModuleType.task方法代码示例

本文整理汇总了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)
开发者ID:wenlien,项目名称:pybuilder,代码行数:11,代码来源:reactor_tests.py

示例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)
开发者ID:wenlien,项目名称:pybuilder,代码行数:15,代码来源:reactor_tests.py

示例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)
开发者ID:wenlien,项目名称:pybuilder,代码行数:16,代码来源:reactor_tests.py

示例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")
开发者ID:wenlien,项目名称:pybuilder,代码行数:17,代码来源:reactor_tests.py

示例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)
开发者ID:wenlien,项目名称:pybuilder,代码行数:17,代码来源:reactor_tests.py

示例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"])
开发者ID:rlugojr,项目名称:pybuilder,代码行数:25,代码来源:reactor_tests.py


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