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


Python TodoList.clean_dependencies方法代码示例

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


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

示例1: TodoListCleanDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import clean_dependencies [as 别名]
class TodoListCleanDependencyTester(TopydoTest):
    def setUp(self):
        super(TodoListCleanDependencyTester, self).setUp()

        self.todolist = TodoList([])
        self.todolist.add("Bar p:1")
        self.todolist.add("Baz p:1 id:2")
        self.todolist.add("Buzz p:2")

    def test_clean_dependencies(self):
        self.todolist.clean_dependencies()

        self.assertFalse(self.todolist.todo(1).has_tag("p"))
        self.assertFalse(self.todolist.todo(2).has_tag("p"))
        self.assertTrue(self.todolist.todo(2).has_tag("id", "2"))
        self.assertTrue(self.todolist.todo(3).has_tag("p", "2"))
开发者ID:netimen,项目名称:topydo,代码行数:18,代码来源:TodoListTest.py

示例2: TodoListCleanDependencyTester

# 需要导入模块: from topydo.lib.TodoList import TodoList [as 别名]
# 或者: from topydo.lib.TodoList.TodoList import clean_dependencies [as 别名]
class TodoListCleanDependencyTester(TopydoTest):
    """
    Tests for cleaning up the graph:

    * Transitive reduction
    * Remove obsolete id: tags
    * Remove obsolete p: tags
    """

    def setUp(self):
        super().setUp()
        self.todolist = TodoList([])

    def test_clean_dependencies1(self):
        """ Clean p: tags from non-existing parent items. """
        self.todolist.add("Bar p:1")
        self.todolist.add("Baz p:1 id:2")
        self.todolist.add("Buzz p:2")

        self.todolist.clean_dependencies()

        self.assertFalse(self.todolist.todo(1).has_tag('p'))
        self.assertFalse(self.todolist.todo(2).has_tag('p'))
        self.assertTrue(self.todolist.todo(2).has_tag('id', '2'))
        self.assertTrue(self.todolist.todo(3).has_tag('p', '2'))

    def test_clean_dependencies2(self):
        """ Clean p: items when siblings are still connected to parent. """
        self.todolist.add("Foo id:1")
        self.todolist.add("Bar p:1")
        self.todolist.add("Baz p:1 id:2")
        self.todolist.add("Buzz p:1 p:2")

        self.todolist.clean_dependencies()

        self.assertFalse(self.todolist.todo(4).has_tag('p', '1'))
        self.assertTrue(self.todolist.todo(1).has_tag('id', '1'))
        self.assertTrue(self.todolist.todo(2).has_tag('p', '1'))

    def test_clean_dependencies3(self):
        """ Clean id: tags from todo items without child todos. """
        self.todolist.add("Foo id:1")

        self.todolist.clean_dependencies()

        self.assertFalse(self.todolist.todo(1).has_tag('id'))
        self.assertFalse(self.todolist.todo_by_dep_id('1'))
开发者ID:rameshg87,项目名称:topydo,代码行数:49,代码来源:test_todo_list.py


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