Commit f4fadceb authored by Bram Schoenmakers's avatar Bram Schoenmakers

Be more defensive about invalid task numbers.

parent db5c890d
......@@ -110,8 +110,10 @@ class TodoList(object):
"""
if len(p_string) > 0:
todo = self.todo(p_number)
new_text = todo.source() + ' ' + p_string
todo.set_text(new_text)
if todo:
new_text = todo.source() + ' ' + p_string
todo.set_text(new_text)
def projects(self):
""" Returns a set of all projects in this list. """
......@@ -160,6 +162,9 @@ class TodoList(object):
from_todo = self.todo(p_number1)
to_todo = self.todo(p_number2)
if not from_todo or not to_todo:
return
dep_id = None
if from_todo.has_tag('id'):
dep_id = from_todo.tag_value('id')
......@@ -174,6 +179,9 @@ class TodoList(object):
from_todo = self.todo(p_number1)
to_todo = self.todo(p_number2)
if not from_todo or not to_todo:
return
dep_id = from_todo.tag_value('id')
if dep_id:
......
......@@ -101,6 +101,9 @@ class TodoListTester(unittest.TestCase):
self.assertEquals(self.todolist.todo(3).text(), text)
def test_append4(self):
self.todolist.append(999, 'foo')
def test_todo(self):
count = self.todolist.count()
todo = self.todolist.todo(count+100)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment