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


Python RootTask.remove_child_task方法代码示例

本文整理汇总了Python中ecpy.tasks.base_tasks.RootTask.remove_child_task方法的典型用法代码示例。如果您正苦于以下问题:Python RootTask.remove_child_task方法的具体用法?Python RootTask.remove_child_task怎么用?Python RootTask.remove_child_task使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ecpy.tasks.base_tasks.RootTask的用法示例。


在下文中一共展示了RootTask.remove_child_task方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_deleting_child

# 需要导入模块: from ecpy.tasks.base_tasks import RootTask [as 别名]
# 或者: from ecpy.tasks.base_tasks.RootTask import remove_child_task [as 别名]
def test_deleting_child():
    """Test deleting a child.

    """
    root = RootTask()
    task1 = ComplexTask(name='task1',
                        database_entries={'val1': 2.0})
    task2 = SimpleTask(name='task2',
                       database_entries={'val2': 1},
                       access_exs={'val2': 2})
    task3 = ComplexTask(name='task3')
    task4 = ComplexTask(name='task4')

    task1.add_child_task(0, task2)
    task1.add_child_task(1, task4)
    root.add_child_task(0, task1)
    root.add_child_task(1, task3)

    listener = SignalListener()
    task1.observe('children_changed', listener.listen)

    task1.remove_child_task(0)

    assert listener.counter == 1
    assert listener.signals[0].removed

    assert task1.preferences['children_0']['name'] == 'task4'
    assert 'task2_val2' not in task3.list_accessible_database_entries()

    root.remove_child_task(0)

    assert len(root.children) == 1
    with pytest.raises(KeyError):
        root.get_from_database('task1_val1')
开发者ID:pombredanne,项目名称:ecpy,代码行数:36,代码来源:test_base_tasks.py

示例2: TestInterfaceableTaskMixin

# 需要导入模块: from ecpy.tasks.base_tasks import RootTask [as 别名]
# 或者: from ecpy.tasks.base_tasks.RootTask import remove_child_task [as 别名]

#.........这里部分代码省略.........
        assert not res
        assert traceback
        assert len(traceback) == 1
        assert 'root/Simple-interface' in traceback

    def test_check4(self):
        """Test handling a non-passing test from the interface.

        """
        self.mixin.interface = InterfaceTest()

        res, traceback = self.mixin.check()
        assert not res
        assert len(traceback) == 1
        assert self.mixin.interface.called

    def test_check5(self):
        """Check that auto-check of fmt and feavl tagged members works.

        """
        self.mixin.interface = InterfaceTest2(fmt='{Simple_test}',
                                              feval='2*{Simple_test}')

        res, traceback = self.mixin.check()
        assert res
        assert not traceback
        assert self.root.get_from_database('Simple_fmt') == '2.0'
        assert self.root.get_from_database('Simple_feval') == 4.0

    def test_check6(self):
        """Check that auto-check of fmt and feavl handle errors.

        """
        self.mixin.interface = InterfaceTest2(fmt='{Simple_test*}',
                                              feval='2*{Simple_test}*')

        res, traceback = self.mixin.check()
        assert not res
        assert self.root.get_from_database('Simple_fmt') == ''
        assert self.root.get_from_database('Simple_feval') == 0
        assert len(traceback) == 2
        assert 'root/Simple-fmt' in traceback
        assert 'root/Simple-feval' in traceback

    def test_perform1(self):
        """Test perform does call interface if present.

        """
        self.mixin.interface = InterfaceTest()
        self.root.database.prepare_to_run()

        self.mixin.perform()
        assert self.mixin.get_from_database('Simple_itest') == 2.0

    def test_perform2(self):
        """Test perform use i_perform when no interface exists.

        """
        self.root.remove_child_task(0)
        self.mixin = IMixin(name='Simple')
        self.root.add_child_task(0, self.mixin)
        self.root.database.prepare_to_run()

        self.mixin.perform()
        assert self.root.get_from_database('Simple_test') == 3.0

    def test_build_from_config1(self):
        """Test building a interfaceable task with no interface from a config.

        """
        aux = RootTask()
        aux.add_child_task(0, IMixin())

        bis = RootTask.build_from_config(aux.preferences,
                                         {'ecpy.task': {'tests.IMixin': IMixin,
                                                        'ecpy.RootTask':
                                                            RootTask}})
        assert type(bis.children[0]).__name__ == 'IMixin'

    def test_build_from_config2(self):
        """Test building a interfaceable task with an interface from a config.

        """
        self.mixin.interface = InterfaceTest(answer=True)
        self.root.update_preferences_from_members()
        deps = {'ecpy.task': {'tests.Mixin': Mixin, 'ecpy.RootTask': RootTask},
                'ecpy.tasks.interface':
                    {('InterfaceTest', ('tests.Mixin',)): InterfaceTest}}
        bis = RootTask.build_from_config(self.root.preferences, deps)

        assert type(bis.children[0].interface).__name__ == 'InterfaceTest'

    def test_traverse(self):
        """Test traversing a task with interface.

        """
        self.mixin.interface = InterfaceTest2()

        w = list(self.mixin.traverse())
        assert w == [self.mixin, self.mixin.interface]
开发者ID:MatthieuDartiailh,项目名称:ecpy,代码行数:104,代码来源:test_task_interfaces.py


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