本文整理汇总了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"))
示例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'))