Commit e1bce272 authored by Bram Schoenmakers's avatar Bram Schoenmakers

When recording a tag, the key and value must be at least one character long.

parent 674947f4
......@@ -105,6 +105,20 @@ class TodoBaseTester(unittest.TestCase):
self.assertFalse(todo.has_tag('foo'))
self.assertFalse(re.search(r'\bfoo:', todo.src))
def test_tag_empty_value(self):
""" Tag should not be recorded when there is no value. """
todo = TodoBase("(C) Foo foo:")
self.assertFalse(todo.has_tag('foo'))
def test_tag_empty_key(self):
""" Tag should not be recorded when there is no key. """
todo = TodoBase("(C) Foo :bar")
self.assertFalse(todo.has_tag(''))
def test_remove_all(self):
todo = TodoBase("(C) Foo foo:bar foo:baz foo:")
todo.remove_tag('foo')
......
......@@ -33,7 +33,7 @@ _NORMAL_HEAD_MATCH = re.compile(
r'(\((?P<priority>[A-Z])\) )?' + '((?P<creationDate>' + _DATE_MATCH +
') )?(?P<rest>.*)')
_TAG_MATCH = re.compile('(?P<key>[^:]*):(?P<value>.*)')
_TAG_MATCH = re.compile('(?P<key>[^:]+):(?P<value>.+)')
_PROJECT_MATCH = re.compile(r'\+(\S*\w)')
_CONTEXT_MATCH = re.compile(r'@(\S*\w)')
......
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