Commit 86ee782b authored by Bram Schoenmakers's avatar Bram Schoenmakers

When an identifier starts with zeroes, treat it as a regexp.

parent 380c1112
...@@ -157,6 +157,14 @@ class DoCommandTest(CommandTest.CommandTest): ...@@ -157,6 +157,14 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertFalse(self.output) self.assertFalse(self.output)
self.assertEquals(self.errors, "Invalid todo number given.\n") self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_invalid3(self):
command = DoCommand(["01"], self.todolist, self.out, self.error, _yes_prompt)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertFalse(self.output)
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_activated_todos1(self): def test_activated_todos1(self):
command = DoCommand(["2"], self.todolist, self.out, self.error) command = DoCommand(["2"], self.todolist, self.out, self.error)
command.execute() command.execute()
......
...@@ -56,6 +56,13 @@ class TodoListBase(object): ...@@ -56,6 +56,13 @@ class TodoListBase(object):
""" """
result = None result = None
try: try:
try:
if not re.match('[1-9]\d*', p_identifier):
raise ValueError # leading zeros, pass to regexp
except TypeError:
# we're dealing with an integer
pass
result = self._todos[int(p_identifier) - 1] result = self._todos[int(p_identifier) - 1]
except IndexError: except IndexError:
raise InvalidTodoException raise InvalidTodoException
......
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